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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/source.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analysis_server.src.status.get_handler; 5 library analysis_server.src.status.get_handler;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 if (count == null) { 632 if (count == null) {
633 count = 1; 633 count = 1;
634 } else { 634 } else {
635 count++; 635 count++;
636 } 636 }
637 counts[key] = count; 637 counts[key] = count;
638 } 638 }
639 Set<AnalysisTarget> countedTargets = new HashSet<AnalysisTarget>(); 639 Set<AnalysisTarget> countedTargets = new HashSet<AnalysisTarget>();
640 Map<String, int> sourceTypeCounts = new HashMap<String, int>(); 640 Map<String, int> sourceTypeCounts = new HashMap<String, int>();
641 Map<String, int> typeCounts = new HashMap<String, int>(); 641 Map<String, int> typeCounts = new HashMap<String, int>();
642 int explicitSourceCount = 0;
643 int explicitLineInfoCount = 0;
644 int explicitLineCount = 0;
645 int implicitSourceCount = 0;
646 int implicitLineInfoCount = 0;
647 int implicitLineCount = 0;
642 analysisServer.folderMap 648 analysisServer.folderMap
643 .forEach((Folder folder, InternalAnalysisContext context) { 649 .forEach((Folder folder, InternalAnalysisContext context) {
650 Set<Source> explicitSources = new HashSet<Source>();
651 Set<Source> implicitSources = new HashSet<Source>();
644 AnalysisCache cache = context.analysisCache; 652 AnalysisCache cache = context.analysisCache;
645 MapIterator<AnalysisTarget, CacheEntry> iterator = cache.iterator(); 653 MapIterator<AnalysisTarget, CacheEntry> iterator = cache.iterator();
646 while (iterator.moveNext()) { 654 while (iterator.moveNext()) {
647 AnalysisTarget target = iterator.key; 655 AnalysisTarget target = iterator.key;
648 if (countedTargets.add(target)) { 656 if (countedTargets.add(target)) {
649 if (target is Source) { 657 if (target is Source) {
650 String name = target.fullName; 658 String name = target.fullName;
651 String sourceName; 659 String sourceName;
652 if (AnalysisEngine.isDartFileName(name)) { 660 if (AnalysisEngine.isDartFileName(name)) {
653 if (iterator.value.explicitlyAdded) { 661 if (iterator.value.explicitlyAdded) {
662 explicitSources.add(target);
654 sourceName = 'Dart file (explicit)'; 663 sourceName = 'Dart file (explicit)';
655 } else { 664 } else {
665 implicitSources.add(target);
656 sourceName = 'Dart file (implicit)'; 666 sourceName = 'Dart file (implicit)';
657 } 667 }
658 } else if (AnalysisEngine.isHtmlFileName(name)) { 668 } else if (AnalysisEngine.isHtmlFileName(name)) {
659 if (iterator.value.explicitlyAdded) { 669 if (iterator.value.explicitlyAdded) {
660 sourceName = 'Html file (explicit)'; 670 sourceName = 'Html file (explicit)';
661 } else { 671 } else {
662 sourceName = 'Html file (implicit)'; 672 sourceName = 'Html file (implicit)';
663 } 673 }
664 } else { 674 } else {
665 if (iterator.value.explicitlyAdded) { 675 if (iterator.value.explicitlyAdded) {
666 sourceName = 'Unknown file (explicit)'; 676 sourceName = 'Unknown file (explicit)';
667 } else { 677 } else {
668 sourceName = 'Unknown file (implicit)'; 678 sourceName = 'Unknown file (implicit)';
669 } 679 }
670 } 680 }
671 incrementCount(sourceTypeCounts, sourceName); 681 incrementCount(sourceTypeCounts, sourceName);
672 } else if (target is ConstantEvaluationTarget) { 682 } else if (target is ConstantEvaluationTarget) {
673 incrementCount(typeCounts, 'ConstantEvaluationTarget'); 683 incrementCount(typeCounts, 'ConstantEvaluationTarget');
674 } else { 684 } else {
675 String typeName = target.runtimeType.toString(); 685 String typeName = target.runtimeType.toString();
676 incrementCount(typeCounts, typeName); 686 incrementCount(typeCounts, typeName);
677 } 687 }
678 } 688 }
679 } 689 }
690
691 int lineCount(Set<Source> sources, bool explicit) {
692 return sources.fold(0, (int previousTotal, Source source) {
693 LineInfo lineInfo = context.getLineInfo(source);
694 if (lineInfo == null) {
695 return previousTotal;
696 }
697 if (explicit) {
698 explicitLineInfoCount++;
699 } else {
700 implicitLineInfoCount++;
701 }
702 return previousTotal + lineInfo.lineCount;
703 });
704 }
705 explicitSourceCount += explicitSources.length;
706 explicitLineCount += lineCount(explicitSources, true);
707 implicitSourceCount += implicitSources.length;
708 implicitLineCount += lineCount(implicitSources, false);
680 }); 709 });
681 List<String> sourceTypeNames = sourceTypeCounts.keys.toList(); 710 List<String> sourceTypeNames = sourceTypeCounts.keys.toList();
682 sourceTypeNames.sort(); 711 sourceTypeNames.sort();
683 List<String> typeNames = typeCounts.keys.toList(); 712 List<String> typeNames = typeCounts.keys.toList();
684 typeNames.sort(); 713 typeNames.sort();
685 714
686 buffer.write('<p><b>Target counts</b></p>'); 715 buffer.write('<p><b>Target counts</b></p>');
687 buffer.write( 716 buffer.write(
688 '<table style="border-collapse: separate; border-spacing: 10px 5px ;">'); 717 '<table style="border-collapse: separate; border-spacing: 10px 5px ;">');
689 _writeRow(buffer, ['Target', 'Count'], header: true); 718 _writeRow(buffer, ['Target', 'Count'], header: true);
690 for (String sourceTypeName in sourceTypeNames) { 719 for (String sourceTypeName in sourceTypeNames) {
691 _writeRow( 720 _writeRow(
692 buffer, [sourceTypeName, sourceTypeCounts[sourceTypeName]], 721 buffer, [sourceTypeName, sourceTypeCounts[sourceTypeName]],
693 classes: [null, "right"]); 722 classes: [null, "right"]);
694 } 723 }
695 for (String typeName in typeNames) { 724 for (String typeName in typeNames) {
696 _writeRow(buffer, [typeName, typeCounts[typeName]], 725 _writeRow(buffer, [typeName, typeCounts[typeName]],
697 classes: [null, "right"]); 726 classes: [null, "right"]);
698 } 727 }
699 buffer.write('</table>'); 728 buffer.write('</table>');
729
730 buffer.write('<p><b>Line counts</b></p>');
731 buffer.write(
732 '<table style="border-collapse: separate; border-spacing: 10px 5px ;">');
733 _writeRow(buffer, ['Kind', 'Lines of Code', 'Source Counts'],
734 header: true);
735 _writeRow(buffer, [
736 'Explicit',
737 explicitLineCount.toString(),
738 '$explicitLineInfoCount / $explicitSourceCount'
739 ], classes: [
740 null,
741 "right"
742 ]);
743 _writeRow(buffer, [
744 'Implicit',
745 implicitLineCount.toString(),
746 '$implicitLineInfoCount / $implicitSourceCount'
747 ], classes: [
748 null,
749 "right"
750 ]);
751 _writeRow(buffer, [
752 'Total',
753 (explicitLineCount + implicitLineCount).toString(),
754 '${explicitLineInfoCount + implicitLineInfoCount} / ${explicitSource Count + implicitSourceCount}'
755 ], classes: [
756 null,
757 "right"
758 ]);
759 buffer.write('</table>');
700 }, (StringBuffer buffer) { 760 }, (StringBuffer buffer) {
701 // 761 //
702 // Write task model timing information. 762 // Write task model timing information.
703 // 763 //
704 buffer.write('<p><b>Task performance data</b></p>'); 764 buffer.write('<p><b>Task performance data</b></p>');
705 buffer.write( 765 buffer.write(
706 '<table style="border-collapse: separate; border-spacing: 10px 5px ;">'); 766 '<table style="border-collapse: separate; border-spacing: 10px 5px ;">');
707 _writeRow( 767 _writeRow(
708 buffer, 768 buffer,
709 [ 769 [
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 */ 2468 */
2409 static String makeLink( 2469 static String makeLink(
2410 String path, Map<String, String> params, String innerHtml, 2470 String path, Map<String, String> params, String innerHtml,
2411 [bool hasError = false]) { 2471 [bool hasError = false]) {
2412 Uri uri = new Uri(path: path, queryParameters: params); 2472 Uri uri = new Uri(path: path, queryParameters: params);
2413 String href = HTML_ESCAPE.convert(uri.toString()); 2473 String href = HTML_ESCAPE.convert(uri.toString());
2414 String classAttribute = hasError ? ' class="error"' : ''; 2474 String classAttribute = hasError ? ' class="error"' : '';
2415 return '<a href="$href"$classAttribute>$innerHtml</a>'; 2475 return '<a href="$href"$classAttribute>$innerHtml</a>';
2416 } 2476 }
2417 } 2477 }
OLDNEW
« 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