| OLD | NEW |
| 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.get_handler; | 5 library analysis_server.src.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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 AnalysisServer analysisServer = _server.analysisServer; | 260 AnalysisServer analysisServer = _server.analysisServer; |
| 261 if (analysisServer == null) { | 261 if (analysisServer == null) { |
| 262 return _returnFailure(request, 'Analysis server is not running'); | 262 return _returnFailure(request, 'Analysis server is not running'); |
| 263 } | 263 } |
| 264 _writeResponse(request, (StringBuffer buffer) { | 264 _writeResponse(request, (StringBuffer buffer) { |
| 265 _writePage( | 265 _writePage( |
| 266 buffer, | 266 buffer, |
| 267 'Analysis Server - Analysis Performance', | 267 'Analysis Server - Analysis Performance', |
| 268 [], | 268 [], |
| 269 (StringBuffer buffer) { | 269 (StringBuffer buffer) { |
| 270 void writeRow(PerformanceTag tag) { | 270 |
| 271 _writeRow(buffer, [tag.elapsedMs, tag.label], classes: ["right", null]
); | 271 buffer.write('<h3>Analysis Performance</h3>'); |
| 272 |
| 273 { |
| 274 buffer.write('<p><b>Time spent in each phase of analysis</b></p>'); |
| 275 buffer.write( |
| 276 '<table style="border-collapse: separate; border-spacing: 10px 5px
;">'); |
| 277 _writeRow( |
| 278 buffer, |
| 279 ['Time (in ms)', 'Percent', 'Analysis Phase'], |
| 280 header: true); |
| 281 // prepare sorted tags |
| 282 List<PerformanceTag> tags = PerformanceTag.all.toList(); |
| 283 tags.remove(ServerPerformanceStatistics.idle); |
| 284 tags.sort((a, b) => b.elapsedMs - a.elapsedMs); |
| 285 // prepare total time |
| 286 int totalTime = 0; |
| 287 tags.forEach((PerformanceTag tag) { |
| 288 totalTime += tag.elapsedMs; |
| 289 }); |
| 290 // write rows |
| 291 void writeRow(PerformanceTag tag) { |
| 292 double percent = (tag.elapsedMs * 100) / totalTime; |
| 293 String percentStr = '${percent.toStringAsFixed(2)}%'; |
| 294 _writeRow( |
| 295 buffer, |
| 296 [tag.elapsedMs, percentStr, tag.label], |
| 297 classes: ["right", "right", null]); |
| 298 } |
| 299 tags.forEach(writeRow); |
| 300 buffer.write('</table>'); |
| 272 } | 301 } |
| 273 | 302 |
| 274 buffer.write('<h3>Analysis Performance</h3>'); | 303 Map<DataDescriptor, Map<CacheState, int>> transitionMap = |
| 275 buffer.write('<p><b>Time spent in each phase of analysis</b></p>'); | 304 SourceEntry.transitionMap; |
| 276 buffer.write( | 305 buffer.write( |
| 277 '<table style="border-collapse: separate; border-spacing: 10px 5px;"
>'); | 306 '<p><b>Number of times a state transitioned to VALID (grouped by des
criptor)</b></p>'); |
| 278 _writeRow(buffer, ['Time (in ms)', 'Analysis Phase'], header: true); | |
| 279 PerformanceTag.all.forEach(writeRow); | |
| 280 buffer.write('</table>'); | |
| 281 | |
| 282 Map<DataDescriptor, Map<CacheState, int>> transitionMap = SourceEntry.tr
ansitionMap; | |
| 283 buffer.write('<p><b>Number of times a state transitioned to VALID (group
ed by descriptor)</b></p>'); | |
| 284 if (transitionMap.isEmpty) { | 307 if (transitionMap.isEmpty) { |
| 285 buffer.write('<p>none</p>'); | 308 buffer.write('<p>none</p>'); |
| 286 } else { | 309 } else { |
| 287 List<DataDescriptor> descriptors = transitionMap.keys.toList(); | 310 List<DataDescriptor> descriptors = transitionMap.keys.toList(); |
| 288 descriptors.sort( | 311 descriptors.sort( |
| 289 (DataDescriptor first, DataDescriptor second) => | 312 (DataDescriptor first, DataDescriptor second) => |
| 290 first.toString().compareTo(second.toString())); | 313 first.toString().compareTo(second.toString())); |
| 291 for (DataDescriptor key in descriptors) { | 314 for (DataDescriptor key in descriptors) { |
| 292 Map<CacheState, int> countMap = transitionMap[key]; | 315 Map<CacheState, int> countMap = transitionMap[key]; |
| 293 List<CacheState> oldStates = countMap.keys.toList(); | 316 List<CacheState> oldStates = countMap.keys.toList(); |
| (...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 * 'error'. | 1650 * 'error'. |
| 1628 */ | 1651 */ |
| 1629 static String makeLink(String path, Map<String, String> params, | 1652 static String makeLink(String path, Map<String, String> params, |
| 1630 String innerHtml, [bool hasError = false]) { | 1653 String innerHtml, [bool hasError = false]) { |
| 1631 Uri uri = new Uri(path: path, queryParameters: params); | 1654 Uri uri = new Uri(path: path, queryParameters: params); |
| 1632 String href = HTML_ESCAPE.convert(uri.toString()); | 1655 String href = HTML_ESCAPE.convert(uri.toString()); |
| 1633 String classAttribute = hasError ? ' class="error"' : ''; | 1656 String classAttribute = hasError ? ' class="error"' : ''; |
| 1634 return '<a href="$href"$classAttribute>$innerHtml</a>'; | 1657 return '<a href="$href"$classAttribute>$innerHtml</a>'; |
| 1635 } | 1658 } |
| 1636 } | 1659 } |
| OLD | NEW |