Updates to the diagnostics page.

BUG=
R=brianwilkerson@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2918533002 .
This commit is contained in:
Devon Carew 2017-05-31 07:15:08 -07:00
parent 499cb29c70
commit 02f7f5fee7
4 changed files with 46 additions and 23 deletions

View file

@ -252,6 +252,15 @@ class AnalysisServer {
*/
ServerPerformance performanceAfterStartup;
/**
* Return the total time the server's been alive.
*/
Duration get uptime {
DateTime start = new DateTime.fromMillisecondsSinceEpoch(
performanceDuringStartup.startTime);
return new DateTime.now().difference(start);
}
/**
* The class into which performance information is currently being recorded.
* During startup, this will be the same as [performanceDuringStartup]

View file

@ -108,6 +108,11 @@ td.pre {
white-space: nowrap;
}
.scroll-table {
max-height: 190px;
overflow-x: auto;
}
.footer {
padding-top: 3rem;
padding-bottom: 3rem;
@ -428,7 +433,7 @@ class ProfilePage extends DiagnosticPageWithNav {
// prepare sorted tags
List<PerformanceTag> tags = PerformanceTag.all.toList();
tags.remove(ServerPerformanceStatistics.idle);
tags.removeWhere((tag) => tag.label == 'unknown');
tags.remove(PerformanceTag.UNKNOWN);
tags.sort((a, b) => b.elapsedMs - a.elapsedMs);
// draw a pie chart
@ -466,8 +471,10 @@ class ProfilePage extends DiagnosticPageWithNav {
buf.write('<th>$d</th>');
}
} else {
for (String d in data) {
buf.write('<td>$d</td>');
buf.write('<td>${data[0]}</td>');
for (String d in data.sublist(1)) {
buf.write('<td class="right">$d</td>');
}
}
buf.writeln('</tr>');
@ -607,20 +614,20 @@ class ContextsPage extends DiagnosticPageWithNav {
h3('Context files');
h4('Priority files ${lenCounter(priorityFiles)}', raw: true);
inputList(priorityFiles, (file) => buf.write(file));
ul(priorityFiles, (file) => buf.write(file), classes: 'scroll-table');
h4('Added files ${lenCounter(addedFiles)}', raw: true);
inputList(addedFiles, (file) => buf.write(file));
ul(addedFiles, (file) => buf.write(file), classes: 'scroll-table');
h4('ImplicitFiles files ${lenCounter(implicitFiles)}', raw: true);
inputList(implicitFiles, (file) => buf.write(file));
ul(implicitFiles, (file) => buf.write(file), classes: 'scroll-table');
SourceFactory sourceFactory = driver.sourceFactory;
if (sourceFactory is SourceFactoryImpl) {
h3('Resolvers');
for (UriResolver resolver in sourceFactory.resolvers) {
h4(resolver.runtimeType.toString());
buf.write('<p>');
buf.write('<p class="scroll-table">');
if (resolver is DartUriResolver) {
DartSdk sdk = resolver.dartSdk;
buf.write(' (sdk = ');
@ -890,8 +897,8 @@ class CommunicationsPage extends DiagnosticPageWithNav {
h3('Current');
int requestCount = perf.requestCount;
double averageLatency =
requestCount > 0 ? (perf.requestLatency / requestCount) : 0.0;
int averageLatency =
requestCount > 0 ? (perf.requestLatency ~/ requestCount) : 0;
int maximumLatency = perf.maxLatency;
double slowRequestPercent =
requestCount > 0 ? (perf.slowRequestCount / requestCount) : 0.0;
@ -906,6 +913,13 @@ class CommunicationsPage extends DiagnosticPageWithNav {
writeRow([printPercentage(slowRequestPercent), '> 150 ms latency'],
classes: ["right", null]);
buf.write('</table>');
String time = server.uptime.toString();
if (time.contains('.')) {
time = time.substring(0, time.indexOf('.'));
}
buf.writeln(writeOption('Uptime', time));
buf.write('</div>');
}
@ -914,8 +928,8 @@ class CommunicationsPage extends DiagnosticPageWithNav {
perf = server.performanceDuringStartup;
int requestCount = perf.requestCount;
double averageLatency =
requestCount > 0 ? (perf.requestLatency / requestCount) : 0.0;
int averageLatency =
requestCount > 0 ? (perf.requestLatency ~/ requestCount) : 0;
int maximumLatency = perf.maxLatency;
double slowRequestPercent =
requestCount > 0 ? (perf.slowRequestCount / requestCount) : 0.0;
@ -934,7 +948,8 @@ class CommunicationsPage extends DiagnosticPageWithNav {
if (server.performanceAfterStartup != null) {
int startupTime =
server.performanceAfterStartup.startTime - perf.startTime;
p('(initial analysis time: ${printMilliseconds(startupTime)})');
buf.writeln(
writeOption('Initial analysis time', printMilliseconds(startupTime)));
}
buf.write('</div>');

View file

@ -5,6 +5,8 @@
import 'dart:convert';
import 'dart:io';
import 'package:intl/intl.dart';
/// Contains a collection of Pages.
abstract class Site {
final String title;
@ -107,8 +109,8 @@ abstract class Page {
buf.writeln('<h4>${raw ? text : escape(text)}</h4>');
}
void ul<T>(Iterable<T> items, void gen(T item)) {
buf.writeln('<ul>');
void ul<T>(Iterable<T> items, void gen(T item), {String classes}) {
buf.writeln('<ul${classes == null ? '' : ' class=$classes'}>');
for (T item in items) {
buf.write('<li>');
gen(item);
@ -156,14 +158,10 @@ abstract class Page {
String escape(String text) => text == null ? '' : HTML_ESCAPE.convert(text);
String printInteger(int value) {
return value.toString();
}
final NumberFormat numberFormat = new NumberFormat.decimalPattern();
String printMilliseconds(num value) {
return '${value.toStringAsFixed(1)} ms';
}
String printInteger(int value) => numberFormat.format(value);
String printPercentage(num value) {
return '${(value * 100).toStringAsFixed(1)}%';
}
String printMilliseconds(num value) => '${numberFormat.format(value)} ms';
String printPercentage(num value) => '${(value * 100).toStringAsFixed(1)}%';

View file

@ -9,6 +9,7 @@ dependencies:
analyzer: ^0.30.0
args: '>=0.13.0 <0.14.0'
dart_style: '^1.0.6'
intl: ^0.14.0
isolate: '>=0.2.2 <2.0.0'
linter: ^0.1.16
logging: any