Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1546)

Unified Diff: pkg/analysis_server/lib/src/status/get_handler.dart

Issue 1622713002: Add a count of total lines to status performance page (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixed bug Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/source.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/status/get_handler.dart
diff --git a/pkg/analysis_server/lib/src/status/get_handler.dart b/pkg/analysis_server/lib/src/status/get_handler.dart
index 37b2e9f3dee18a3e54035096e1acd1151ffed461..b97ef3ba678916c8a9823a5119f2e6f14f049372 100644
--- a/pkg/analysis_server/lib/src/status/get_handler.dart
+++ b/pkg/analysis_server/lib/src/status/get_handler.dart
@@ -639,8 +639,16 @@ class GetHandler {
Set<AnalysisTarget> countedTargets = new HashSet<AnalysisTarget>();
Map<String, int> sourceTypeCounts = new HashMap<String, int>();
Map<String, int> typeCounts = new HashMap<String, int>();
+ int explicitSourceCount = 0;
+ int explicitLineInfoCount = 0;
+ int explicitLineCount = 0;
+ int implicitSourceCount = 0;
+ int implicitLineInfoCount = 0;
+ int implicitLineCount = 0;
analysisServer.folderMap
.forEach((Folder folder, InternalAnalysisContext context) {
+ Set<Source> explicitSources = new HashSet<Source>();
+ Set<Source> implicitSources = new HashSet<Source>();
AnalysisCache cache = context.analysisCache;
MapIterator<AnalysisTarget, CacheEntry> iterator = cache.iterator();
while (iterator.moveNext()) {
@@ -651,8 +659,10 @@ class GetHandler {
String sourceName;
if (AnalysisEngine.isDartFileName(name)) {
if (iterator.value.explicitlyAdded) {
+ explicitSources.add(target);
sourceName = 'Dart file (explicit)';
} else {
+ implicitSources.add(target);
sourceName = 'Dart file (implicit)';
}
} else if (AnalysisEngine.isHtmlFileName(name)) {
@@ -677,6 +687,25 @@ class GetHandler {
}
}
}
+
+ int lineCount(Set<Source> sources, bool explicit) {
+ return sources.fold(0, (int previousTotal, Source source) {
+ LineInfo lineInfo = context.getLineInfo(source);
+ if (lineInfo == null) {
+ return previousTotal;
+ }
+ if (explicit) {
+ explicitLineInfoCount++;
+ } else {
+ implicitLineInfoCount++;
+ }
+ return previousTotal + lineInfo.lineCount;
+ });
+ }
+ explicitSourceCount += explicitSources.length;
+ explicitLineCount += lineCount(explicitSources, true);
+ implicitSourceCount += implicitSources.length;
+ implicitLineCount += lineCount(implicitSources, false);
});
List<String> sourceTypeNames = sourceTypeCounts.keys.toList();
sourceTypeNames.sort();
@@ -697,6 +726,37 @@ class GetHandler {
classes: [null, "right"]);
}
buffer.write('</table>');
+
+ buffer.write('<p><b>Line counts</b></p>');
+ buffer.write(
+ '<table style="border-collapse: separate; border-spacing: 10px 5px;">');
+ _writeRow(buffer, ['Kind', 'Lines of Code', 'Source Counts'],
+ header: true);
+ _writeRow(buffer, [
+ 'Explicit',
+ explicitLineCount.toString(),
+ '$explicitLineInfoCount / $explicitSourceCount'
+ ], classes: [
+ null,
+ "right"
+ ]);
+ _writeRow(buffer, [
+ 'Implicit',
+ implicitLineCount.toString(),
+ '$implicitLineInfoCount / $implicitSourceCount'
+ ], classes: [
+ null,
+ "right"
+ ]);
+ _writeRow(buffer, [
+ 'Total',
+ (explicitLineCount + implicitLineCount).toString(),
+ '${explicitLineInfoCount + implicitLineInfoCount} / ${explicitSourceCount + implicitSourceCount}'
+ ], classes: [
+ null,
+ "right"
+ ]);
+ buffer.write('</table>');
}, (StringBuffer buffer) {
//
// Write task model timing information.
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698