Skip to content

Commit 1e5a270

Browse files
jensjohaCommit Queue
authored andcommitted
[analysis_server] Add 'Analysis Driver Timings' and 'FileByteStore Timings' to report
These were added as tabs in the "Analysis Server Diagnostics" interface, but never added to the downloadable report. This CL further more fixes the "FileByteStore Timings" not showing the last item. Change-Id: I41c77b83b0356c3d3fdf7c8e5e1b4c5e3995d66d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412581 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent 067f881 commit 1e5a270

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

pkg/analysis_server/lib/src/status/diagnostics.dart

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,14 @@ class ByteStoreTimingPage extends DiagnosticPageWithNav
346346
buf.writeln(
347347
'<tr><th>Files Read</th><th>Time Taken</th><th>&nbsp;</th></tr>',
348348
);
349-
for (var i = 0; i < byteStoreTimings.length - 1; i++) {
349+
for (var i = 0; i < byteStoreTimings.length; i++) {
350350
var timing = byteStoreTimings[i];
351351
if (timing.readCount == 0) {
352352
continue;
353353
}
354354

355355
var nextTiming =
356-
i <= byteStoreTimings.length ? byteStoreTimings[i + 1] : null;
356+
i + 1 < byteStoreTimings.length ? byteStoreTimings[i + 1] : null;
357357
var duration = (nextTiming?.time ?? DateTime.now()).difference(
358358
timing.time,
359359
);
@@ -491,6 +491,47 @@ class CollectReportPage extends DiagnosticPage {
491491
}
492492
collectedData['uniqueKnownFiles'] = uniqueKnownFiles.length;
493493

494+
// Data from the 'Analysis Driver Timings' page.
495+
var buffer = StringBuffer();
496+
server.analysisDriverScheduler.accumulatedPerformance.write(buffer: buffer);
497+
collectedData['accumulatedPerformance'] = buffer.toString();
498+
499+
// FileByteStore timings
500+
{
501+
var byteStoreTimings =
502+
server.byteStoreTimings
503+
?.where(
504+
(timing) =>
505+
timing.readCount != 0 || timing.readTime != Duration.zero,
506+
)
507+
.toList();
508+
if (byteStoreTimings != null && byteStoreTimings.isNotEmpty) {
509+
var performance = [];
510+
collectedData['byteStoreTimings'] = performance;
511+
for (var i = 0; i < byteStoreTimings.length; i++) {
512+
var timing = byteStoreTimings[i];
513+
if (timing.readCount == 0) {
514+
continue;
515+
}
516+
517+
var nextTiming =
518+
i + 1 < byteStoreTimings.length ? byteStoreTimings[i + 1] : null;
519+
var duration = (nextTiming?.time ?? DateTime.now()).difference(
520+
timing.time,
521+
);
522+
var description =
523+
'Between ${timing.reason} and ${nextTiming?.reason ?? 'now'} '
524+
'(${printMilliseconds(duration.inMilliseconds)}).';
525+
526+
var itemData = {};
527+
performance.add(itemData);
528+
itemData['file_reads'] = timing.readCount;
529+
itemData['time'] = timing.readTime.inMilliseconds;
530+
itemData['description'] = description;
531+
}
532+
}
533+
}
534+
494535
// Recorded performance data (timing and code completion).
495536
void collectPerformance(List<RequestPerformance> items, String type) {
496537
var performance = [];

0 commit comments

Comments
 (0)