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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/completion_performance.dart

Issue 1536083002: completion performance measurement for local status page (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: rebase Created 5 years 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
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 services.completion.manager; 5 library services.completion.manager;
6 6
7 import 'package:analyzer/src/generated/source.dart'; 7 import 'package:analyzer/src/generated/source.dart';
8 8
9 /** 9 /**
10 * Overall performance of a code completion operation. 10 * Overall performance of a code completion operation.
(...skipping 27 matching lines...) Expand all
38 if (notificationCount < 1) return ''; 38 if (notificationCount < 1) return '';
39 if (notificationCount == 1) return '$suggestionCountFirst'; 39 if (notificationCount == 1) return '$suggestionCountFirst';
40 return '$suggestionCountFirst, $suggestionCountLast'; 40 return '$suggestionCountFirst, $suggestionCountLast';
41 } 41 }
42 42
43 void complete([String tag = null]) { 43 void complete([String tag = null]) {
44 _stopwatch.stop(); 44 _stopwatch.stop();
45 _logDuration(tag != null ? tag : 'total time', _stopwatch.elapsed); 45 _logDuration(tag != null ? tag : 'total time', _stopwatch.elapsed);
46 } 46 }
47 47
48 logElapseTime(String tag, [f() = null]) { 48 void logElapseTime(String tag) {
49 Duration start;
50 Duration end = _stopwatch.elapsed; 49 Duration end = _stopwatch.elapsed;
51 var result; 50 Duration start = _startTimes[tag];
52 if (f == null) { 51 if (start == null) {
53 start = _startTimes[tag]; 52 _logDuration(tag, null);
54 if (start == null) { 53 return null;
55 _logDuration(tag, null);
56 return null;
57 }
58 } else {
59 result = f();
60 start = end;
61 end = _stopwatch.elapsed;
62 } 54 }
63 _logDuration(tag, end - start); 55 _logDuration(tag, end - start);
64 return result;
65 } 56 }
66 57
67 void logFirstNotificationComplete(String tag) { 58 void logFirstNotificationComplete(String tag) {
68 _firstNotification = _stopwatch.elapsed; 59 _firstNotification = _stopwatch.elapsed;
69 _logDuration(tag, _firstNotification); 60 _logDuration(tag, _firstNotification);
70 } 61 }
71 62
72 void logStartTime(String tag) { 63 void logStartTime(String tag) {
73 _startTimes[tag] = _stopwatch.elapsed; 64 _startTimes[tag] = _stopwatch.elapsed;
74 } 65 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 */ 110 */
120 final String name; 111 final String name;
121 112
122 /** 113 /**
123 * The elapse time or `null` if undefined. 114 * The elapse time or `null` if undefined.
124 */ 115 */
125 final Duration elapsed; 116 final Duration elapsed;
126 117
127 OperationPerformance(this.name, this.elapsed); 118 OperationPerformance(this.name, this.elapsed);
128 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698