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

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

Issue 889583004: fix race condition when recording computeCache performance (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/domain_completion.dart ('k') | 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:collection'; 7 import 'dart:collection';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:math'; 10 import 'dart:math';
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 308 }
309 String sourceUri = request.uri.queryParameters[SOURCE_QUERY_PARAM]; 309 String sourceUri = request.uri.queryParameters[SOURCE_QUERY_PARAM];
310 if (sourceUri == null) { 310 if (sourceUri == null) {
311 return _returnFailure( 311 return _returnFailure(
312 request, 312 request,
313 'Query parameter $SOURCE_QUERY_PARAM required'); 313 'Query parameter $SOURCE_QUERY_PARAM required');
314 } 314 }
315 315
316 List<Folder> allContexts = <Folder>[]; 316 List<Folder> allContexts = <Folder>[];
317 Map<Folder, SourceEntry> entryMap = new HashMap<Folder, SourceEntry>(); 317 Map<Folder, SourceEntry> entryMap = new HashMap<Folder, SourceEntry>();
318 analysisServer.folderMap.forEach((Folder folder, AnalysisContextImpl context ) { 318 analysisServer.folderMap.forEach(
319 (Folder folder, AnalysisContextImpl context) {
319 Source source = context.sourceFactory.forUri(sourceUri); 320 Source source = context.sourceFactory.forUri(sourceUri);
320 if (source != null) { 321 if (source != null) {
321 SourceEntry entry = context.getReadableSourceEntryOrNull(source); 322 SourceEntry entry = context.getReadableSourceEntryOrNull(source);
322 if (entry != null) { 323 if (entry != null) {
323 allContexts.add(folder); 324 allContexts.add(folder);
324 entryMap[folder] = entry; 325 entryMap[folder] = entry;
325 } 326 }
326 } 327 }
327 }); 328 });
328 allContexts.sort((Folder firstFolder, Folder secondFolder) => firstFolder.pa th.compareTo(secondFolder.path)); 329 allContexts.sort(
330 (Folder firstFolder, Folder secondFolder) =>
331 firstFolder.path.compareTo(secondFolder.path));
329 AnalysisContextImpl context = analysisServer.folderMap[folder]; 332 AnalysisContextImpl context = analysisServer.folderMap[folder];
330 333
331 _writeResponse(request, (StringBuffer buffer) { 334 _writeResponse(request, (StringBuffer buffer) {
332 _writePage( 335 _writePage(
333 buffer, 336 buffer,
334 'Analysis Server - Cache Entry', 337 'Analysis Server - Cache Entry',
335 ['Context: $contextFilter', 'File: $sourceUri'], 338 ['Context: $contextFilter', 'File: $sourceUri'],
336 (HttpResponse) { 339 (HttpResponse) {
337 buffer.write('<h3>Analyzing Contexts</h3><p>'); 340 buffer.write('<h3>Analyzing Contexts</h3><p>');
338 bool first = true; 341 bool first = true;
339 allContexts.forEach((Folder folder) { 342 allContexts.forEach((Folder folder) {
340 if (first) { 343 if (first) {
341 first = false; 344 first = false;
342 } else { 345 } else {
343 buffer.write('<br>'); 346 buffer.write('<br>');
344 } 347 }
345 AnalysisContextImpl analyzingContext = analysisServer.folderMap[folder ]; 348 AnalysisContextImpl analyzingContext =
349 analysisServer.folderMap[folder];
346 if (analyzingContext == context) { 350 if (analyzingContext == context) {
347 buffer.write(folder.path); 351 buffer.write(folder.path);
348 } else { 352 } else {
349 buffer.write(_makeLink(CACHE_ENTRY_PATH, { 353 buffer.write(_makeLink(CACHE_ENTRY_PATH, {
350 CONTEXT_QUERY_PARAM: folder.path, 354 CONTEXT_QUERY_PARAM: folder.path,
351 SOURCE_QUERY_PARAM: sourceUri 355 SOURCE_QUERY_PARAM: sourceUri
352 }, HTML_ESCAPE.convert(folder.path))); 356 }, HTML_ESCAPE.convert(folder.path)));
353 } 357 }
354 if (entryMap[folder].explicitlyAdded) { 358 if (entryMap[folder].explicitlyAdded) {
355 buffer.write(' (explicit)'); 359 buffer.write(' (explicit)');
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 }); 480 });
477 } 481 }
478 482
479 /** 483 /**
480 * Return a response displaying code completion information. 484 * Return a response displaying code completion information.
481 */ 485 */
482 void _returnCompletionInfo(HttpRequest request) { 486 void _returnCompletionInfo(HttpRequest request) {
483 String value = request.requestedUri.queryParameters['index']; 487 String value = request.requestedUri.queryParameters['index'];
484 int index = value != null ? int.parse(value, onError: (_) => 0) : 0; 488 int index = value != null ? int.parse(value, onError: (_) => 0) : 0;
485 _writeResponse(request, (StringBuffer buffer) { 489 _writeResponse(request, (StringBuffer buffer) {
486 _writePage(buffer, 'Analysis Server - Completion Stats', [], (StringBuffer buffer) { 490 _writePage(
491 buffer,
492 'Analysis Server - Completion Stats',
493 [],
494 (StringBuffer buffer) {
487 _writeCompletionPerformanceDetail(buffer, index); 495 _writeCompletionPerformanceDetail(buffer, index);
488 _writeCompletionPerformanceList(buffer); 496 _writeCompletionPerformanceList(buffer);
489 }); 497 });
490 }); 498 });
491 } 499 }
492 500
493 /** 501 /**
494 * Return a response containing information about a single source file in the 502 * Return a response containing information about a single source file in the
495 * cache. 503 * cache.
496 */ 504 */
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 List<CompletionPerformance> list = handler.performanceList; 887 List<CompletionPerformance> list = handler.performanceList;
880 if (list != null && list.isNotEmpty) { 888 if (list != null && list.isNotEmpty) {
881 performance = list[max(0, min(list.length - 1, index))]; 889 performance = list[max(0, min(list.length - 1, index))];
882 } 890 }
883 } 891 }
884 if (performance == null) { 892 if (performance == null) {
885 buffer.write('<h3>Completion Performance Detail</h3>'); 893 buffer.write('<h3>Completion Performance Detail</h3>');
886 buffer.write('<p>No completions yet</p>'); 894 buffer.write('<p>No completions yet</p>');
887 return; 895 return;
888 } 896 }
889 buffer.write( 897 buffer.write('<h3>Completion Performance Detail</h3>');
890 '<h3>Completion Performance Detail - ${performance.startTimeAndMs}</h3>' ); 898 buffer.write('<p>${performance.startTimeAndMs} for ${performance.source}');
891 buffer.write('<table>'); 899 buffer.write('<table>');
892 _writeRow(buffer, ['Elapsed', '', 'Operation'], header: true); 900 _writeRow(buffer, ['Elapsed', '', 'Operation'], header: true);
893 performance.operations.forEach((OperationPerformance op) { 901 performance.operations.forEach((OperationPerformance op) {
894 String elapsed = op.elapsed != null ? op.elapsed.toString() : '???'; 902 String elapsed = op.elapsed != null ? op.elapsed.toString() : '???';
895 _writeRow(buffer, [elapsed, '&nbsp;&nbsp;', op.name]); 903 _writeRow(buffer, [elapsed, '&nbsp;&nbsp;', op.name]);
896 }); 904 });
897 if (handler.priorityChangedPerformance == null) { 905 buffer.write('</table>');
898 buffer.write('<p>No priorityChanged caching</p>'); 906 buffer.write('<p><b>Compute Cache Performance</b>: ');
907 if (handler.computeCachePerformance == null) {
908 buffer.write('none');
899 } else { 909 } else {
900 int len = handler.priorityChangedPerformance.operations.length; 910 int elapsed = handler.computeCachePerformance.elapsedInMilliseconds;
901 if (len > 0) { 911 Source source = handler.computeCachePerformance.source;
902 var op = handler.priorityChangedPerformance.operations[len - 1]; 912 buffer.write(' $elapsed ms for $source');
903 if (op != null) {
904 _writeRow(buffer, ['&nbsp;', '&nbsp;', '&nbsp;']);
905 String elapsed = op.elapsed != null ? op.elapsed.toString() : '???';
906 _writeRow(buffer, [elapsed, '&nbsp;&nbsp;', op.name]);
907 }
908 }
909 } 913 }
910 buffer.write('</table>'); 914 buffer.write('</p>');
911 } 915 }
912 916
913 /** 917 /**
914 * Write a table showing summary information for the last several 918 * Write a table showing summary information for the last several
915 * completion requests to the given [buffer] object. 919 * completion requests to the given [buffer] object.
916 */ 920 */
917 void _writeCompletionPerformanceList(StringBuffer buffer) { 921 void _writeCompletionPerformanceList(StringBuffer buffer) {
918 CompletionDomainHandler handler = _completionDomainHandler; 922 CompletionDomainHandler handler = _completionDomainHandler;
919 buffer.write('<h3>Completion Performance</h3>'); 923 buffer.write('<h3>Completion Performance List</h3>');
920 if (handler == null) { 924 if (handler == null) {
921 return; 925 return;
922 } 926 }
923 buffer.write('<table>'); 927 buffer.write('<table>');
924 _writeRow( 928 _writeRow(
925 buffer, 929 buffer,
926 [ 930 [
927 'Start Time', 931 'Start Time',
928 '', 932 '',
929 'First (ms)', 933 'First (ms)',
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 } finally { 1191 } finally {
1188 response.close(); 1192 response.close();
1189 } 1193 }
1190 } 1194 }
1191 1195
1192 /** 1196 /**
1193 * Write a single row within a table to the given [buffer]. The row will have 1197 * Write a single row within a table to the given [buffer]. The row will have
1194 * one cell for each of the [columns], and will be a header row if [header] is 1198 * one cell for each of the [columns], and will be a header row if [header] is
1195 * `true`. 1199 * `true`.
1196 */ 1200 */
1197 void _writeRow(StringBuffer buffer, List<Object> columns, {bool header: 1201 void _writeRow(StringBuffer buffer, List<Object> columns, {bool header: false,
1198 false, List<String> classes}) { 1202 List<String> classes}) {
1199 buffer.write('<tr>'); 1203 buffer.write('<tr>');
1200 int count = columns.length; 1204 int count = columns.length;
1201 int maxClassIndex = classes == null ? 0 : classes.length - 1; 1205 int maxClassIndex = classes == null ? 0 : classes.length - 1;
1202 for (int i = 0; i < count; i++) { 1206 for (int i = 0; i < count; i++) {
1203 String classAttribute = ''; 1207 String classAttribute = '';
1204 if (classes != null) { 1208 if (classes != null) {
1205 String className = classes[min(i, maxClassIndex)]; 1209 String className = classes[min(i, maxClassIndex)];
1206 if (className != null) { 1210 if (className != null) {
1207 classAttribute = ' class="$className"'; 1211 classAttribute = ' class="$className"';
1208 } 1212 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 } else if (value is Element) { 1384 } else if (value is Element) {
1381 String link = 1385 String link =
1382 _makeLink(ELEMENT_PATH, linkParameters, value.runtimeType.toString()); 1386 _makeLink(ELEMENT_PATH, linkParameters, value.runtimeType.toString());
1383 buffer.write('<i>$link</i>'); 1387 buffer.write('<i>$link</i>');
1384 } else { 1388 } else {
1385 buffer.write(HTML_ESCAPE.convert(value.toString())); 1389 buffer.write(HTML_ESCAPE.convert(value.toString()));
1386 buffer.write(' <i>(${value.runtimeType.toString()})</i>'); 1390 buffer.write(' <i>(${value.runtimeType.toString()})</i>');
1387 } 1391 }
1388 } 1392 }
1389 } 1393 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/domain_completion.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698