Chromium Code Reviews| 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 int percent = (tag.elapsedMs * 100) ~/ totalTime; | |
|
Paul Berry
2015/02/24 17:45:22
This will round down to percent granularity. I do
| |
| 293 _writeRow( | |
| 294 buffer, | |
| 295 [tag.elapsedMs, '$percent%', tag.label], | |
| 296 classes: ["right", "right", null]); | |
| 297 } | |
| 298 tags.forEach(writeRow); | |
| 299 buffer.write('</table>'); | |
| 272 } | 300 } |
| 273 | 301 |
| 274 buffer.write('<h3>Analysis Performance</h3>'); | 302 Map<DataDescriptor, Map<CacheState, int>> transitionMap = |
| 275 buffer.write('<p><b>Time spent in each phase of analysis</b></p>'); | 303 SourceEntry.transitionMap; |
| 276 buffer.write( | 304 buffer.write( |
| 277 '<table style="border-collapse: separate; border-spacing: 10px 5px;" >'); | 305 '<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) { | 306 if (transitionMap.isEmpty) { |
| 285 buffer.write('<p>none</p>'); | 307 buffer.write('<p>none</p>'); |
| 286 } else { | 308 } else { |
| 287 List<DataDescriptor> descriptors = transitionMap.keys.toList(); | 309 List<DataDescriptor> descriptors = transitionMap.keys.toList(); |
| 288 descriptors.sort( | 310 descriptors.sort( |
| 289 (DataDescriptor first, DataDescriptor second) => | 311 (DataDescriptor first, DataDescriptor second) => |
| 290 first.toString().compareTo(second.toString())); | 312 first.toString().compareTo(second.toString())); |
| 291 for (DataDescriptor key in descriptors) { | 313 for (DataDescriptor key in descriptors) { |
| 292 Map<CacheState, int> countMap = transitionMap[key]; | 314 Map<CacheState, int> countMap = transitionMap[key]; |
| 293 List<CacheState> oldStates = countMap.keys.toList(); | 315 List<CacheState> oldStates = countMap.keys.toList(); |
| (...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1627 * 'error'. | 1649 * 'error'. |
| 1628 */ | 1650 */ |
| 1629 static String makeLink(String path, Map<String, String> params, | 1651 static String makeLink(String path, Map<String, String> params, |
| 1630 String innerHtml, [bool hasError = false]) { | 1652 String innerHtml, [bool hasError = false]) { |
| 1631 Uri uri = new Uri(path: path, queryParameters: params); | 1653 Uri uri = new Uri(path: path, queryParameters: params); |
| 1632 String href = HTML_ESCAPE.convert(uri.toString()); | 1654 String href = HTML_ESCAPE.convert(uri.toString()); |
| 1633 String classAttribute = hasError ? ' class="error"' : ''; | 1655 String classAttribute = hasError ? ' class="error"' : ''; |
| 1634 return '<a href="$href"$classAttribute>$innerHtml</a>'; | 1656 return '<a href="$href"$classAttribute>$innerHtml</a>'; |
| 1635 } | 1657 } |
| 1636 } | 1658 } |
| OLD | NEW |