| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:convert'; | 6 import 'dart:convert'; |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:analysis_server/protocol/protocol_generated.dart'; | 9 import 'package:analysis_server/protocol/protocol_generated.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| (...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 | 981 |
| 982 List<Plugin> plugins = [ | 982 List<Plugin> plugins = [ |
| 983 AnalysisEngine.instance.enginePlugin, | 983 AnalysisEngine.instance.enginePlugin, |
| 984 server.serverPlugin | 984 server.serverPlugin |
| 985 ]; | 985 ]; |
| 986 plugins.addAll(server.userDefinedPlugins); | 986 plugins.addAll(server.userDefinedPlugins); |
| 987 ul(plugins, writePlugin); | 987 ul(plugins, writePlugin); |
| 988 } | 988 } |
| 989 } | 989 } |
| 990 | 990 |
| 991 // TODO(devoncarew): Show the last x requests and responses. | |
| 992 class ProfilePage extends DiagnosticPageWithNav { | 991 class ProfilePage extends DiagnosticPageWithNav { |
| 993 ProfilePage(DiagnosticsSite site) | 992 ProfilePage(DiagnosticsSite site) |
| 994 : super(site, 'profile', 'Profiling Info', | 993 : super(site, 'profile', 'Profiling Info', |
| 995 description: 'Profiling performance tag data.'); | 994 description: 'Profiling performance tag data and lint timings.'); |
| 996 | 995 |
| 997 @override | 996 @override |
| 998 void generateContent(Map<String, String> params) { | 997 void generateContent(Map<String, String> params) { |
| 998 h3('Profiling performance tag data'); |
| 999 |
| 999 // prepare sorted tags | 1000 // prepare sorted tags |
| 1000 List<PerformanceTag> tags = PerformanceTag.all.toList(); | 1001 List<PerformanceTag> tags = PerformanceTag.all.toList(); |
| 1001 tags.remove(ServerPerformanceStatistics.idle); | 1002 tags.remove(ServerPerformanceStatistics.idle); |
| 1002 tags.remove(PerformanceTag.unknown); | 1003 tags.remove(PerformanceTag.unknown); |
| 1003 tags.removeWhere((tag) => tag.elapsedMs == 0); | 1004 tags.removeWhere((tag) => tag.elapsedMs == 0); |
| 1004 tags.sort((a, b) => b.elapsedMs - a.elapsedMs); | 1005 tags.sort((a, b) => b.elapsedMs - a.elapsedMs); |
| 1005 | 1006 |
| 1007 // print total time |
| 1008 int totalTime = |
| 1009 tags.fold<int>(0, (int a, PerformanceTag tag) => a + tag.elapsedMs); |
| 1010 p('Total measured time: ${printMilliseconds(totalTime)}'); |
| 1011 |
| 1006 // draw a pie chart | 1012 // draw a pie chart |
| 1007 String rowData = | 1013 String rowData = |
| 1008 tags.map((tag) => "['${tag.label}', ${tag.elapsedMs}]").join(','); | 1014 tags.map((tag) => "['${tag.label}', ${tag.elapsedMs}]").join(','); |
| 1009 buf.writeln( | 1015 buf.writeln( |
| 1010 '<div id="chart-div" style="width: 700px; height: 300px;"></div>'); | 1016 '<div id="chart-div" style="width: 700px; height: 300px;"></div>'); |
| 1011 buf.writeln(''' | 1017 buf.writeln(''' |
| 1012 <script type="text/javascript"> | 1018 <script type="text/javascript"> |
| 1013 google.charts.load('current', {'packages':['corechart']}); | 1019 google.charts.load('current', {'packages':['corechart']}); |
| 1014 google.charts.setOnLoadCallback(drawChart); | 1020 google.charts.setOnLoadCallback(drawChart); |
| 1015 | 1021 |
| 1016 function drawChart() { | 1022 function drawChart() { |
| 1017 var data = new google.visualization.DataTable(); | 1023 var data = new google.visualization.DataTable(); |
| 1018 data.addColumn('string', 'Tag'); | 1024 data.addColumn('string', 'Tag'); |
| 1019 data.addColumn('number', 'Time (ms)'); | 1025 data.addColumn('number', 'Time (ms)'); |
| 1020 data.addRows([$rowData]); | 1026 data.addRows([$rowData]); |
| 1021 var options = {'title': 'Performance Tag Data', 'width': 700, 'height'
: 300}; | 1027 var options = {'title': 'Performance Tag Data', 'width': 700, 'height'
: 300}; |
| 1022 var chart = new google.visualization.PieChart(document.getElementById(
'chart-div')); | 1028 var chart = new google.visualization.PieChart(document.getElementById(
'chart-div')); |
| 1023 chart.draw(data, options); | 1029 chart.draw(data, options); |
| 1024 } | 1030 } |
| 1025 </script> | 1031 </script> |
| 1026 '''); | 1032 '''); |
| 1027 | 1033 |
| 1028 // print total time | |
| 1029 int totalTime = | |
| 1030 tags.fold<int>(0, (int a, PerformanceTag tag) => a + tag.elapsedMs); | |
| 1031 p('Total measured time: ${printMilliseconds(totalTime)}'); | |
| 1032 | |
| 1033 // write out a table | 1034 // write out a table |
| 1034 void _writeRow(List<String> data, {bool header: false}) { | 1035 void _writeRow(List<String> data, {bool header: false}) { |
| 1035 buf.write('<tr>'); | 1036 buf.write('<tr>'); |
| 1036 if (header) { | 1037 if (header) { |
| 1037 for (String d in data) { | 1038 for (String d in data) { |
| 1038 buf.write('<th>$d</th>'); | 1039 buf.write('<th>$d</th>'); |
| 1039 } | 1040 } |
| 1040 } else { | 1041 } else { |
| 1041 buf.write('<td>${data[0]}</td>'); | 1042 buf.write('<td>${data[0]}</td>'); |
| 1042 | 1043 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1054 _writeRow([ | 1055 _writeRow([ |
| 1055 tag.label, | 1056 tag.label, |
| 1056 printMilliseconds(tag.elapsedMs), | 1057 printMilliseconds(tag.elapsedMs), |
| 1057 printPercentage(percent) | 1058 printPercentage(percent) |
| 1058 ]); | 1059 ]); |
| 1059 } | 1060 } |
| 1060 | 1061 |
| 1061 tags.forEach(writeRow); | 1062 tags.forEach(writeRow); |
| 1062 buf.write('</table>'); | 1063 buf.write('</table>'); |
| 1063 | 1064 |
| 1065 h3('Lint rule timings'); |
| 1064 List<LintRule> rules = Registry.ruleRegistry.rules.toList(); | 1066 List<LintRule> rules = Registry.ruleRegistry.rules.toList(); |
| 1067 int totalLintTime = rules.fold(0, |
| 1068 (sum, rule) => sum + lintRegistry.getTimer(rule).elapsedMilliseconds); |
| 1069 p('Total time spent in lints: ${printMilliseconds(totalLintTime)}'); |
| 1070 |
| 1065 rules.sort((first, second) { | 1071 rules.sort((first, second) { |
| 1066 int firstTime = lintRegistry.getTimer(first).elapsedMilliseconds; | 1072 int firstTime = lintRegistry.getTimer(first).elapsedMilliseconds; |
| 1067 int secondTime = lintRegistry.getTimer(second).elapsedMilliseconds; | 1073 int secondTime = lintRegistry.getTimer(second).elapsedMilliseconds; |
| 1068 if (firstTime == secondTime) { | 1074 if (firstTime == secondTime) { |
| 1069 return first.lintCode.name.compareTo(second.lintCode.name); | 1075 return first.lintCode.name.compareTo(second.lintCode.name); |
| 1070 } | 1076 } |
| 1071 return secondTime - firstTime; | 1077 return secondTime - firstTime; |
| 1072 }); | 1078 }); |
| 1073 p('Lint rule timings'); | |
| 1074 buf.write('<table>'); | 1079 buf.write('<table>'); |
| 1075 _writeRow(['Lint code', 'Time (in ms)'], header: true); | 1080 _writeRow(['Lint code', 'Time (in ms)'], header: true); |
| 1076 int totalLintTime = 0; | |
| 1077 for (var rule in rules) { | 1081 for (var rule in rules) { |
| 1078 int time = lintRegistry.getTimer(rule).elapsedMilliseconds; | 1082 int time = lintRegistry.getTimer(rule).elapsedMilliseconds; |
| 1079 totalLintTime += time; | 1083 _writeRow([rule.lintCode.name, printMilliseconds(time)]); |
| 1080 _writeRow([rule.lintCode.name, time.toString()]); | |
| 1081 } | 1084 } |
| 1082 buf.write('</table>'); | 1085 buf.write('</table>'); |
| 1083 p('Total time spent in lints: $totalLintTime ms'); | |
| 1084 } | 1086 } |
| 1085 } | 1087 } |
| 1086 | 1088 |
| 1087 class StatusPage extends DiagnosticPageWithNav { | 1089 class StatusPage extends DiagnosticPageWithNav { |
| 1088 StatusPage(DiagnosticsSite site) | 1090 StatusPage(DiagnosticsSite site) |
| 1089 : super(site, 'status', 'Status', | 1091 : super(site, 'status', 'Status', |
| 1090 description: | 1092 description: |
| 1091 'General status and diagnostics for the analysis server.'); | 1093 'General status and diagnostics for the analysis server.'); |
| 1092 | 1094 |
| 1093 @override | 1095 @override |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 h3('Execution domain'); | 1153 h3('Execution domain'); |
| 1152 ul(ExecutionService.VALUES, (item) { | 1154 ul(ExecutionService.VALUES, (item) { |
| 1153 if (domain.onFileAnalyzed != null) { | 1155 if (domain.onFileAnalyzed != null) { |
| 1154 buf.write('$item (has subscriptions)'); | 1156 buf.write('$item (has subscriptions)'); |
| 1155 } else { | 1157 } else { |
| 1156 buf.write('$item (no subscriptions)'); | 1158 buf.write('$item (no subscriptions)'); |
| 1157 } | 1159 } |
| 1158 }); | 1160 }); |
| 1159 } | 1161 } |
| 1160 } | 1162 } |
| OLD | NEW |