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

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

Issue 861153003: improve measurement of completion performance (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: slightly adjust text Created 5 years, 11 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/get_handler.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 services.completion.computer; 5 library services.completion.computer;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 10 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 class CompletionPerformance { 117 class CompletionPerformance {
118 final DateTime start = new DateTime.now(); 118 final DateTime start = new DateTime.now();
119 final Map<String, Duration> _startTimes = new Map<String, Duration>(); 119 final Map<String, Duration> _startTimes = new Map<String, Duration>();
120 final Stopwatch _stopwatch = new Stopwatch(); 120 final Stopwatch _stopwatch = new Stopwatch();
121 final List<OperationPerformance> operations = <OperationPerformance>[]; 121 final List<OperationPerformance> operations = <OperationPerformance>[];
122 122
123 Source source; 123 Source source;
124 int offset; 124 int offset;
125 String contents; 125 String contents;
126 int notificationCount = -1; 126 int notificationCount = -1;
127 int suggestionCount = -1; 127 int suggestionCountFirst = -1;
128 int suggestionCountLast = -1;
128 Duration _firstNotification; 129 Duration _firstNotification;
129 130
130 CompletionPerformance() { 131 CompletionPerformance() {
131 _stopwatch.start(); 132 _stopwatch.start();
132 } 133 }
133 134
134 int get elapsedInMilliseconds => 135 int get elapsedInMilliseconds =>
135 operations.length > 0 ? operations.last.elapsed.inMilliseconds : 0; 136 operations.length > 0 ? operations.last.elapsed.inMilliseconds : 0;
136 137
137 int get firstNotificationInMilliseconds => 138 int get firstNotificationInMilliseconds =>
(...skipping 17 matching lines...) Expand all
155 if (ch == '\r' || ch == '\n') { 156 if (ch == '\r' || ch == '\n') {
156 break; 157 break;
157 } 158 }
158 ++end; 159 ++end;
159 } 160 }
160 String prefix = contents.substring(start, offset); 161 String prefix = contents.substring(start, offset);
161 String suffix = contents.substring(offset, end); 162 String suffix = contents.substring(offset, end);
162 return '$prefix^$suffix'; 163 return '$prefix^$suffix';
163 } 164 }
164 165
166 String get startTimeAndMs => '${start.millisecondsSinceEpoch} - $start';
167
168 String get suggestionCount {
169 if (notificationCount < 1) return '';
170 if (notificationCount == 1) return '$suggestionCountFirst';
171 return '$suggestionCountFirst, $suggestionCountLast';
172 }
173
165 void complete([String tag = null]) { 174 void complete([String tag = null]) {
166 _stopwatch.stop(); 175 _stopwatch.stop();
167 _logDuration(tag != null ? tag : 'total time', _stopwatch.elapsed); 176 _logDuration(tag != null ? tag : 'total time', _stopwatch.elapsed);
168 } 177 }
169 178
170 logElapseTime(String tag, [f() = null]) { 179 logElapseTime(String tag, [f() = null]) {
171 Duration start; 180 Duration start;
172 Duration end = _stopwatch.elapsed; 181 Duration end = _stopwatch.elapsed;
173 var result; 182 var result;
174 if (f == null) { 183 if (f == null) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 */ 281 */
273 final String name; 282 final String name;
274 283
275 /** 284 /**
276 * The elapse time or `null` if undefined. 285 * The elapse time or `null` if undefined.
277 */ 286 */
278 final Duration elapsed; 287 final Duration elapsed;
279 288
280 OperationPerformance(this.name, this.elapsed); 289 OperationPerformance(this.name, this.elapsed);
281 } 290 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/get_handler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698