33// BSD-style license that can be found in the LICENSE file.
44
55import 'dart:async' ;
6+ import 'dart:convert' ;
67
78import 'package:analysis_server/src/scheduler/message_scheduler.dart' ;
89import 'package:analysis_server/src/scheduler/scheduler_tracking_listener.dart' ;
@@ -35,17 +36,20 @@ class MessageSchedulerPage extends DiagnosticPageWithNav {
3536 return ;
3637 }
3738
38- void writeData (MessageData data, {required bool isActive}) {
39- p (data.message.id);
40- buf.write ('<blockquote>' );
41- p ('Pending messages ahead of this: ${data .pendingMessageCount }' );
39+ void writeRow (MessageData data, {required bool isActive}) {
4240 var pendingDuration = (data.activeTime ?? now) - data.pendingTime;
43- p ('Time spent on pending queue: $pendingDuration ' );
41+ buf.writeln ('<tr>' );
42+ buf.writeln ('<td>${data .message .id }</td>' );
43+ buf.writeln ('<td>${data .pendingMessageCount }</td>' );
44+ buf.writeln ('<td>$pendingDuration </td>' );
4445 if (isActive) {
45- p ('Active messages ahead of this: ${data .activeMessageCount }' );
46- p ('Time spent running: ${now - data .activeTime !}' );
46+ buf.writeln ('<td>${data .activeMessageCount }</td>' );
47+ buf.writeln ('<td>${now - data .activeTime !}</td>' );
48+ } else {
49+ buf.writeln ('<td>-</td>' );
50+ buf.writeln ('<td>-</td>' );
4751 }
48- buf.write ('</blockquote >' );
52+ buf.writeln ('</tr >' );
4953 }
5054
5155 var (: pending, : active) = listener.pendingAndActiveMessages;
@@ -57,9 +61,14 @@ class MessageSchedulerPage extends DiagnosticPageWithNav {
5761 pending.sort (
5862 (first, second) => first.pendingTime.compareTo (second.pendingTime),
5963 );
64+ buf.writeln ('<table>' );
65+ buf.writeln (
66+ '<tr><th>Message ID</th><th>Pending Ahead</th><th>Time in Pending</th><th>Active Ahead</th><th>Time Running</th></tr>' ,
67+ );
6068 for (var data in pending) {
61- writeData (data, isActive: false );
69+ writeRow (data, isActive: false );
6270 }
71+ buf.writeln ('</table>' );
6372 }
6473
6574 h3 ('Active messages' );
@@ -69,15 +78,35 @@ class MessageSchedulerPage extends DiagnosticPageWithNav {
6978 active.sort (
7079 (first, second) => first.activeTime! .compareTo (second.activeTime! ),
7180 );
81+ buf.writeln ('<table>' );
82+ buf.writeln (
83+ '<tr><th>Message ID</th><th>Pending Ahead</th><th>Time in Pending</th><th>Active Ahead</th><th>Time Running</th></tr>' ,
84+ );
7285 for (var data in active) {
73- writeData (data, isActive: true );
86+ writeRow (data, isActive: true );
7487 }
88+ buf.writeln ('</table>' );
7589 }
7690
7791 var lines = listener.completedMessageLog;
7892 if (lines.isNotEmpty) {
7993 h3 ('Completed messages' );
80- p (lines.join ('\n ' ), style: 'white-space: pre' );
94+ buf.writeln ('<table>' );
95+ buf.writeln (
96+ '<tr><th>Message</th><th>Pending Count</th><th>Active Count</th><th>Pending Duration</th><th>Active Duration</th><th>Cancelled</th></tr>' ,
97+ );
98+ for (var line in lines) {
99+ var data = jsonDecode (line) as Map <String , dynamic >;
100+ buf.writeln ('<tr>' );
101+ buf.writeln ('<td>${data ['message' ]}</td>' );
102+ buf.writeln ('<td>${data ['pendingMessageCount' ]}</td>' );
103+ buf.writeln ('<td>${data ['activeMessageCount' ]}</td>' );
104+ buf.writeln ('<td>${data ['pendingDuration' ]}</td>' );
105+ buf.writeln ('<td>${data ['activeDuration' ]}</td>' );
106+ buf.writeln ('<td>${data ['wasCancelled' ]}</td>' );
107+ buf.writeln ('</tr>' );
108+ }
109+ buf.writeln ('</table>' );
81110 }
82111 }
83112}
0 commit comments