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

Side by Side Diff: pkg/analysis_server/lib/src/get_handler.dart

Issue 1161183004: Another tweak for displaying performance. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/task/driver.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.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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 */ 255 */
256 void _returnAnalysisPerformance(HttpRequest request) { 256 void _returnAnalysisPerformance(HttpRequest request) {
257 AnalysisServer analysisServer = _server.analysisServer; 257 AnalysisServer analysisServer = _server.analysisServer;
258 if (analysisServer == null) { 258 if (analysisServer == null) {
259 return _returnFailure(request, 'Analysis server is not running'); 259 return _returnFailure(request, 'Analysis server is not running');
260 } 260 }
261 _writeResponse(request, (StringBuffer buffer) { 261 _writeResponse(request, (StringBuffer buffer) {
262 _writePage(buffer, 'Analysis Server - Analysis Performance', [], 262 _writePage(buffer, 'Analysis Server - Analysis Performance', [],
263 (StringBuffer buffer) { 263 (StringBuffer buffer) {
264 buffer.write('<h3>Analysis Performance</h3>'); 264 buffer.write('<h3>Analysis Performance</h3>');
265
266 //
267 // Write performance tags.
268 //
269 {
270 buffer.write('<p><b>Time spent in each phase of analysis</b></p>');
271 buffer.write(
272 '<table style="border-collapse: separate; border-spacing: 10px 5px ;">');
273 _writeRow(buffer, ['Time (in ms)', 'Percent', 'Analysis Phase'],
274 header: true);
275 // prepare sorted tags
276 List<PerformanceTag> tags = PerformanceTag.all.toList();
277 tags.remove(ServerPerformanceStatistics.idle);
278 tags.sort((a, b) => b.elapsedMs - a.elapsedMs);
279 // prepare total time
280 int totalTime = 0;
281 tags.forEach((PerformanceTag tag) {
282 totalTime += tag.elapsedMs;
283 });
284 // write rows
285 void writeRow(PerformanceTag tag) {
286 double percent = (tag.elapsedMs * 100) / totalTime;
287 String percentStr = '${percent.toStringAsFixed(2)}%';
288 _writeRow(buffer, [tag.elapsedMs, percentStr, tag.label],
289 classes: ["right", "right", null]);
290 }
291 tags.forEach(writeRow);
292 buffer.write('</table>');
293 }
294
295 //
296 // Write new task model timing information.
297 //
265 if (AnalysisEngine.instance.useTaskModel) { 298 if (AnalysisEngine.instance.useTaskModel) {
266 //
267 // Write new task model timing information.
268 //
269 buffer.write('<p><b>Task performace data</b></p>'); 299 buffer.write('<p><b>Task performace data</b></p>');
270 buffer.write( 300 buffer.write(
271 '<table style="border-collapse: separate; border-spacing: 10px 5px ;">'); 301 '<table style="border-collapse: separate; border-spacing: 10px 5px ;">');
272 _writeRow(buffer, [ 302 _writeRow(buffer, [
273 'Task Name', 303 'Task Name',
274 'Count', 304 'Count',
275 'Total Time (in ms)', 305 'Total Time (in ms)',
276 'Average Time (in ms)' 306 'Average Time (in ms)'
277 ], header: true); 307 ], header: true);
278 308
279 Map<Type, int> countMap = newTask.AnalysisTask.countMap; 309 Map<Type, int> countMap = newTask.AnalysisTask.countMap;
280 Map<Type, Stopwatch> stopwatchMap = newTask.AnalysisTask.stopwatchMap; 310 Map<Type, Stopwatch> stopwatchMap = newTask.AnalysisTask.stopwatchMap;
281 List<Type> taskClasses = stopwatchMap.keys.toList(); 311 List<Type> taskClasses = stopwatchMap.keys.toList();
282 taskClasses.sort((Type first, Type second) => 312 taskClasses.sort((Type first, Type second) =>
283 first.toString().compareTo(second.toString())); 313 first.toString().compareTo(second.toString()));
314 int totalTime = 0;
284 taskClasses.forEach((Type taskClass) { 315 taskClasses.forEach((Type taskClass) {
285 int count = countMap[taskClass]; 316 int count = countMap[taskClass];
286 if (count == null) { 317 if (count == null) {
287 count = 0; 318 count = 0;
288 } 319 }
289 int totalTime = stopwatchMap[taskClass].elapsedMilliseconds; 320 int taskTime = stopwatchMap[taskClass].elapsedMilliseconds;
321 totalTime += taskTime;
290 _writeRow(buffer, [ 322 _writeRow(buffer, [
291 taskClass.toString(), 323 taskClass.toString(),
292 count, 324 count,
293 totalTime, 325 taskTime,
294 count <= 0 ? '-' : (totalTime / count).toStringAsFixed(3) 326 count <= 0 ? '-' : (taskTime / count).toStringAsFixed(3)
295 ], classes: [null, "right", "right", "right"]); 327 ], classes: [null, "right", "right", "right"]);
296 }); 328 });
329 _writeRow(buffer, ['Total', '-', totalTime, '-'],
330 classes: [null, "right", "right", "right"]);
297 buffer.write('</table>'); 331 buffer.write('</table>');
298 } else { 332 }
299 //
300 // Write old task model timing information.
301 //
302 {
303 buffer.write('<p><b>Time spent in each phase of analysis</b></p>');
304 buffer.write(
305 '<table style="border-collapse: separate; border-spacing: 10px 5 px;">');
306 _writeRow(buffer, ['Time (in ms)', 'Percent', 'Analysis Phase'],
307 header: true);
308 // prepare sorted tags
309 List<PerformanceTag> tags = PerformanceTag.all.toList();
310 tags.remove(ServerPerformanceStatistics.idle);
311 tags.sort((a, b) => b.elapsedMs - a.elapsedMs);
312 // prepare total time
313 int totalTime = 0;
314 tags.forEach((PerformanceTag tag) {
315 totalTime += tag.elapsedMs;
316 });
317 // write rows
318 void writeRow(PerformanceTag tag) {
319 double percent = (tag.elapsedMs * 100) / totalTime;
320 String percentStr = '${percent.toStringAsFixed(2)}%';
321 _writeRow(buffer, [tag.elapsedMs, percentStr, tag.label],
322 classes: ["right", "right", null]);
323 }
324 tags.forEach(writeRow);
325 buffer.write('</table>');
326 }
327 333
334 //
335 // Write old task model transition information.
336 //
337 {
328 Map<DataDescriptor, Map<CacheState, int>> transitionMap = 338 Map<DataDescriptor, Map<CacheState, int>> transitionMap =
329 SourceEntry.transitionMap; 339 SourceEntry.transitionMap;
330 buffer.write( 340 buffer.write(
331 '<p><b>Number of times a state transitioned to VALID (grouped by d escriptor)</b></p>'); 341 '<p><b>Number of times a state transitioned to VALID (grouped by d escriptor)</b></p>');
332 if (transitionMap.isEmpty) { 342 if (transitionMap.isEmpty) {
333 buffer.write('<p>none</p>'); 343 buffer.write('<p>none</p>');
334 } else { 344 } else {
335 List<DataDescriptor> descriptors = transitionMap.keys.toList(); 345 List<DataDescriptor> descriptors = transitionMap.keys.toList();
336 descriptors.sort((DataDescriptor first, DataDescriptor second) => 346 descriptors.sort((DataDescriptor first, DataDescriptor second) =>
337 first.toString().compareTo(second.toString())); 347 first.toString().compareTo(second.toString()));
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 */ 1626 */
1617 static String makeLink( 1627 static String makeLink(
1618 String path, Map<String, String> params, String innerHtml, 1628 String path, Map<String, String> params, String innerHtml,
1619 [bool hasError = false]) { 1629 [bool hasError = false]) {
1620 Uri uri = new Uri(path: path, queryParameters: params); 1630 Uri uri = new Uri(path: path, queryParameters: params);
1621 String href = HTML_ESCAPE.convert(uri.toString()); 1631 String href = HTML_ESCAPE.convert(uri.toString());
1622 String classAttribute = hasError ? ' class="error"' : ''; 1632 String classAttribute = hasError ? ' class="error"' : '';
1623 return '<a href="$href"$classAttribute>$innerHtml</a>'; 1633 return '<a href="$href"$classAttribute>$innerHtml</a>';
1624 } 1634 }
1625 } 1635 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/driver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698