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

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

Issue 1169573003: Expose timing data for the new task model (Closed) Base URL: https://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 | no next file » | 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 12 matching lines...) Expand all
23 import 'package:analysis_server/src/socket_server.dart'; 23 import 'package:analysis_server/src/socket_server.dart';
24 import 'package:analysis_server/src/status/ast_writer.dart'; 24 import 'package:analysis_server/src/status/ast_writer.dart';
25 import 'package:analysis_server/src/status/element_writer.dart'; 25 import 'package:analysis_server/src/status/element_writer.dart';
26 import 'package:analyzer/file_system/file_system.dart'; 26 import 'package:analyzer/file_system/file_system.dart';
27 import 'package:analyzer/src/generated/ast.dart'; 27 import 'package:analyzer/src/generated/ast.dart';
28 import 'package:analyzer/src/generated/element.dart'; 28 import 'package:analyzer/src/generated/element.dart';
29 import 'package:analyzer/src/generated/engine.dart'; 29 import 'package:analyzer/src/generated/engine.dart';
30 import 'package:analyzer/src/generated/java_engine.dart'; 30 import 'package:analyzer/src/generated/java_engine.dart';
31 import 'package:analyzer/src/generated/source.dart'; 31 import 'package:analyzer/src/generated/source.dart';
32 import 'package:analyzer/src/generated/utilities_general.dart'; 32 import 'package:analyzer/src/generated/utilities_general.dart';
33 import 'package:analyzer/task/model.dart' as newTask;
33 import 'package:plugin/plugin.dart'; 34 import 'package:plugin/plugin.dart';
34 35
35 /** 36 /**
36 * A function that can be used to generate HTML output into the given [buffer]. 37 * A function that can be used to generate HTML output into the given [buffer].
37 * The HTML that is generated must be valid (special characters must already be 38 * The HTML that is generated must be valid (special characters must already be
38 * encoded). 39 * encoded).
39 */ 40 */
40 typedef void HtmlGenerator(StringBuffer buffer); 41 typedef void HtmlGenerator(StringBuffer buffer);
41 42
42 /** 43 /**
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 */ 255 */
255 void _returnAnalysisPerformance(HttpRequest request) { 256 void _returnAnalysisPerformance(HttpRequest request) {
256 AnalysisServer analysisServer = _server.analysisServer; 257 AnalysisServer analysisServer = _server.analysisServer;
257 if (analysisServer == null) { 258 if (analysisServer == null) {
258 return _returnFailure(request, 'Analysis server is not running'); 259 return _returnFailure(request, 'Analysis server is not running');
259 } 260 }
260 _writeResponse(request, (StringBuffer buffer) { 261 _writeResponse(request, (StringBuffer buffer) {
261 _writePage(buffer, 'Analysis Server - Analysis Performance', [], 262 _writePage(buffer, 'Analysis Server - Analysis Performance', [],
262 (StringBuffer buffer) { 263 (StringBuffer buffer) {
263 buffer.write('<h3>Analysis Performance</h3>'); 264 buffer.write('<h3>Analysis Performance</h3>');
264 265 if (AnalysisEngine.instance.useTaskModel) {
265 { 266 //
266 buffer.write('<p><b>Time spent in each phase of analysis</b></p>'); 267 // Write new task model timing information.
268 //
269 buffer.write('<p><b>Task performace data</b></p>');
267 buffer.write( 270 buffer.write(
268 '<table style="border-collapse: separate; border-spacing: 10px 5px ;">'); 271 '<table style="border-collapse: separate; border-spacing: 10px 5px ;">');
269 _writeRow(buffer, ['Time (in ms)', 'Percent', 'Analysis Phase'], 272 _writeRow(buffer, [
270 header: true); 273 'Task Name',
271 // prepare sorted tags 274 'Count',
272 List<PerformanceTag> tags = PerformanceTag.all.toList(); 275 'Total Time (in ms)',
273 tags.remove(ServerPerformanceStatistics.idle); 276 'Average Time (in ms)'
274 tags.sort((a, b) => b.elapsedMs - a.elapsedMs); 277 ], header: true);
275 // prepare total time 278
276 int totalTime = 0; 279 Map<Type, int> countMap = newTask.AnalysisTask.countMap;
277 tags.forEach((PerformanceTag tag) { 280 Map<Type, Stopwatch> stopwatchMap = newTask.AnalysisTask.stopwatchMap;
278 totalTime += tag.elapsedMs; 281 List<Type> taskClasses = stopwatchMap.keys.toList();
282 taskClasses.sort((Type first, Type second) =>
283 first.toString().compareTo(second.toString()));
284 taskClasses.forEach((Type taskClass) {
285 int count = countMap[taskClass];
286 if (count == null) {
287 count = 0;
288 }
289 int totalTime = stopwatchMap[taskClass].elapsedMilliseconds;
290 _writeRow(buffer, [
291 taskClass.toString(),
292 count,
293 totalTime,
294 count <= 0 ? '-' : totalTime / count
295 ], classes: [null, "right", "right", "right"]);
279 }); 296 });
280 // write rows
281 void writeRow(PerformanceTag tag) {
282 double percent = (tag.elapsedMs * 100) / totalTime;
283 String percentStr = '${percent.toStringAsFixed(2)}%';
284 _writeRow(buffer, [tag.elapsedMs, percentStr, tag.label],
285 classes: ["right", "right", null]);
286 }
287 tags.forEach(writeRow);
288 buffer.write('</table>'); 297 buffer.write('</table>');
289 }
290
291 Map<DataDescriptor, Map<CacheState, int>> transitionMap =
292 SourceEntry.transitionMap;
293 buffer.write(
294 '<p><b>Number of times a state transitioned to VALID (grouped by des criptor)</b></p>');
295 if (transitionMap.isEmpty) {
296 buffer.write('<p>none</p>');
297 } else { 298 } else {
298 List<DataDescriptor> descriptors = transitionMap.keys.toList(); 299 //
299 descriptors.sort((DataDescriptor first, DataDescriptor second) => 300 // Write old task model timing information.
300 first.toString().compareTo(second.toString())); 301 //
301 for (DataDescriptor key in descriptors) { 302 {
302 Map<CacheState, int> countMap = transitionMap[key]; 303 buffer.write('<p><b>Time spent in each phase of analysis</b></p>');
303 List<CacheState> oldStates = countMap.keys.toList();
304 oldStates.sort((CacheState first, CacheState second) =>
305 first.toString().compareTo(second.toString()));
306 buffer.write('<p>${key.toString()}</p>');
307 buffer.write( 304 buffer.write(
308 '<table style="border-collapse: separate; border-spacing: 10px 5 px;">'); 305 '<table style="border-collapse: separate; border-spacing: 10px 5 px;">');
309 _writeRow(buffer, ['Count', 'Previous State'], header: true); 306 _writeRow(buffer, ['Time (in ms)', 'Percent', 'Analysis Phase'],
310 for (CacheState state in oldStates) { 307 header: true);
311 _writeRow(buffer, [countMap[state], state.toString()], 308 // prepare sorted tags
312 classes: ["right", null]); 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]);
313 } 323 }
324 tags.forEach(writeRow);
314 buffer.write('</table>'); 325 buffer.write('</table>');
315 } 326 }
327
328 Map<DataDescriptor, Map<CacheState, int>> transitionMap =
329 SourceEntry.transitionMap;
330 buffer.write(
331 '<p><b>Number of times a state transitioned to VALID (grouped by d escriptor)</b></p>');
332 if (transitionMap.isEmpty) {
333 buffer.write('<p>none</p>');
334 } else {
335 List<DataDescriptor> descriptors = transitionMap.keys.toList();
336 descriptors.sort((DataDescriptor first, DataDescriptor second) =>
337 first.toString().compareTo(second.toString()));
338 for (DataDescriptor key in descriptors) {
339 Map<CacheState, int> countMap = transitionMap[key];
340 List<CacheState> oldStates = countMap.keys.toList();
341 oldStates.sort((CacheState first, CacheState second) =>
342 first.toString().compareTo(second.toString()));
343 buffer.write('<p>${key.toString()}</p>');
344 buffer.write(
345 '<table style="border-collapse: separate; border-spacing: 10px 5px;">');
346 _writeRow(buffer, ['Count', 'Previous State'], header: true);
347 for (CacheState state in oldStates) {
348 _writeRow(buffer, [countMap[state], state.toString()],
349 classes: ["right", null]);
350 }
351 buffer.write('</table>');
352 }
353 }
316 } 354 }
317 }); 355 });
318 }); 356 });
319 } 357 }
320 358
321 /** 359 /**
322 * Return a response containing information about an AST structure. 360 * Return a response containing information about an AST structure.
323 */ 361 */
324 void _returnAst(HttpRequest request) { 362 void _returnAst(HttpRequest request) {
325 AnalysisServer analysisServer = _server.analysisServer; 363 AnalysisServer analysisServer = _server.analysisServer;
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 */ 1616 */
1579 static String makeLink( 1617 static String makeLink(
1580 String path, Map<String, String> params, String innerHtml, 1618 String path, Map<String, String> params, String innerHtml,
1581 [bool hasError = false]) { 1619 [bool hasError = false]) {
1582 Uri uri = new Uri(path: path, queryParameters: params); 1620 Uri uri = new Uri(path: path, queryParameters: params);
1583 String href = HTML_ESCAPE.convert(uri.toString()); 1621 String href = HTML_ESCAPE.convert(uri.toString());
1584 String classAttribute = hasError ? ' class="error"' : ''; 1622 String classAttribute = hasError ? ' class="error"' : '';
1585 return '<a href="$href"$classAttribute>$innerHtml</a>'; 1623 return '<a href="$href"$classAttribute>$innerHtml</a>';
1586 } 1624 }
1587 } 1625 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698