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

Side by Side Diff: pkg/analysis_server/test/performance/driver.dart

Issue 1221893003: performance measurement improvements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 server.driver; 5 library server.driver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:math' show max; 8 import 'dart:math' show max, sqrt;
9 9
10 import 'package:analyzer/src/generated/engine.dart' as engine;
10 import 'package:logging/logging.dart'; 11 import 'package:logging/logging.dart';
11 12
12 import '../integration/integration_test_methods.dart'; 13 import '../integration/integration_test_methods.dart';
13 import '../integration/integration_tests.dart'; 14 import '../integration/integration_tests.dart';
14 import 'operation.dart'; 15 import 'operation.dart';
15 16
16 final SPACE = ' '.codeUnitAt(0); 17 final SPACE = ' '.codeUnitAt(0);
17 18
18 void _printColumn(StringBuffer sb, String text, int keyLen, 19 void _printColumn(StringBuffer sb, String text, int keyLen,
19 {bool rightJustified: false}) { 20 {bool rightJustified: false}) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 * error response, the future will be completed with an error. 90 * error response, the future will be completed with an error.
90 */ 91 */
91 Future send(String method, Map<String, dynamic> params) { 92 Future send(String method, Map<String, dynamic> params) {
92 return server.send(method, params); 93 return server.send(method, params);
93 } 94 }
94 95
95 /** 96 /**
96 * Launch the analysis server. 97 * Launch the analysis server.
97 * Return a [Future] that completes when analysis server has started. 98 * Return a [Future] that completes when analysis server has started.
98 */ 99 */
99 Future startServer() async { 100 Future startServer({int diagnosticPort}) async {
100 logger.log(Level.FINE, 'starting server'); 101 logger.log(Level.FINE, 'starting server');
101 initializeInttestMixin(); 102 initializeInttestMixin();
102 server = new Server(); 103 server = new Server();
103 Completer serverConnected = new Completer(); 104 Completer serverConnected = new Completer();
104 onServerConnected.listen((_) { 105 onServerConnected.listen((_) {
105 logger.log(Level.FINE, 'connected to server'); 106 logger.log(Level.FINE, 'connected to server');
106 serverConnected.complete(); 107 serverConnected.complete();
107 }); 108 });
108 running = true; 109 running = true;
109 return server.start(/*profileServer: true*/).then((params) { 110 return server
111 .start(diagnosticPort: diagnosticPort /*profileServer: true*/)
112 .then((params) {
110 server.listenToOutput(dispatchNotification); 113 server.listenToOutput(dispatchNotification);
111 server.exitCode.then((_) { 114 server.exitCode.then((_) {
112 logger.log(Level.FINE, 'server stopped'); 115 logger.log(Level.FINE, 'server stopped');
113 running = false; 116 running = false;
114 _resultsReady(); 117 _resultsReady();
115 }); 118 });
116 return serverConnected.future; 119 return serverConnected.future;
117 }); 120 });
118 } 121 }
119 122
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 Duration maxTime = elapsedTimes[0]; 165 Duration maxTime = elapsedTimes[0];
163 Duration minTime = elapsedTimes[0]; 166 Duration minTime = elapsedTimes[0];
164 int totalTimeMicros = 0; 167 int totalTimeMicros = 0;
165 for (Duration elapsed in elapsedTimes) { 168 for (Duration elapsed in elapsedTimes) {
166 ++count; 169 ++count;
167 int timeMicros = elapsed.inMicroseconds; 170 int timeMicros = elapsed.inMicroseconds;
168 maxTime = maxTime.compareTo(elapsed) > 0 ? maxTime : elapsed; 171 maxTime = maxTime.compareTo(elapsed) > 0 ? maxTime : elapsed;
169 minTime = minTime.compareTo(elapsed) < 0 ? minTime : elapsed; 172 minTime = minTime.compareTo(elapsed) < 0 ? minTime : elapsed;
170 totalTimeMicros += timeMicros; 173 totalTimeMicros += timeMicros;
171 } 174 }
172 int averageTimeMicros = (totalTimeMicros / count).round(); 175 int meanTime = (totalTimeMicros / count).round();
176 List<Duration> sorted = elapsedTimes.toList()..sort();
177 Duration time90th = sorted[(sorted.length * 0.90).round() - 1];
178 Duration time99th = sorted[(sorted.length * 0.99).round() - 1];
179 int differenceFromMeanSquared = 0;
180 for (Duration elapsed in elapsedTimes) {
181 int timeMicros = elapsed.inMicroseconds;
182 int differenceFromMean = timeMicros - meanTime;
183 differenceFromMeanSquared += differenceFromMean * differenceFromMean;
184 }
185 double variance = differenceFromMeanSquared / count;
186 int standardDeviation = sqrt(variance).round();
187
173 StringBuffer sb = new StringBuffer(); 188 StringBuffer sb = new StringBuffer();
174 _printColumn(sb, tag, keyLen); 189 _printColumn(sb, tag, keyLen);
175 _printColumn(sb, count.toString(), 6, rightJustified: true); 190 _printColumn(sb, count.toString(), 6, rightJustified: true);
176 _printColumn(sb, errorCount.toString(), 6, rightJustified: true); 191 _printColumn(sb, errorCount.toString(), 6, rightJustified: true);
177 _printColumn(sb, unexpectedResultCount.toString(), 6, rightJustified: true); 192 _printColumn(sb, unexpectedResultCount.toString(), 6, rightJustified: true);
193 _printDuration(sb, new Duration(microseconds: meanTime));
194 _printDuration(sb, time90th);
195 _printDuration(sb, time99th);
196 _printColumn(sb, standardDeviation.toString(), 15, rightJustified: true);
178 _printDuration(sb, minTime); 197 _printDuration(sb, minTime);
179 _printDuration(sb, new Duration(microseconds: averageTimeMicros));
180 _printDuration(sb, maxTime); 198 _printDuration(sb, maxTime);
181 _printDuration(sb, new Duration(microseconds: totalTimeMicros)); 199 _printDuration(sb, new Duration(microseconds: totalTimeMicros));
182 print(sb.toString()); 200 print(sb.toString());
183 } 201 }
184 202
185 void record(bool success, Duration elapsed) { 203 void record(bool success, Duration elapsed) {
186 if (!success) { 204 if (!success) {
187 ++errorCount; 205 ++errorCount;
188 } 206 }
189 elapsedTimes.add(elapsed); 207 elapsedTimes.add(elapsed);
(...skipping 16 matching lines...) Expand all
206 */ 224 */
207 class Results { 225 class Results {
208 Map<String, Measurement> measurements = new Map<String, Measurement>(); 226 Map<String, Measurement> measurements = new Map<String, Measurement>();
209 227
210 /** 228 /**
211 * Display results on stdout. 229 * Display results on stdout.
212 */ 230 */
213 void printResults() { 231 void printResults() {
214 print(''); 232 print('');
215 print('=================================================================='); 233 print('==================================================================');
234 if (engine.AnalysisEngine.instance.useTaskModel) {
235 print('New task model');
236 } else {
237 print('Old task model');
238 }
216 print(''); 239 print('');
217 List<String> keys = measurements.keys.toList()..sort(); 240 List<String> keys = measurements.keys.toList()..sort();
218 int keyLen = keys.fold(0, (int len, String key) => max(len, key.length)); 241 int keyLen = keys.fold(0, (int len, String key) => max(len, key.length));
219 _printGroupHeader('Request/Response', keyLen); 242 _printGroupHeader('Request/Response', keyLen);
220 int totalCount = 0; 243 int totalCount = 0;
221 int totalErrorCount = 0; 244 int totalErrorCount = 0;
222 int totalUnexpectedResultCount = 0; 245 int totalUnexpectedResultCount = 0;
223 for (String tag in keys) { 246 for (String tag in keys) {
224 Measurement m = measurements[tag]; 247 Measurement m = measurements[tag];
225 if (!m.notification) { 248 if (!m.notification) {
226 m.printSummary(keyLen); 249 m.printSummary(keyLen);
227 totalCount += m.count; 250 totalCount += m.count;
228 totalErrorCount += m.errorCount; 251 totalErrorCount += m.errorCount;
229 totalUnexpectedResultCount += m.unexpectedResultCount; 252 totalUnexpectedResultCount += m.unexpectedResultCount;
230 } 253 }
231 } 254 }
232 _printTotals(keyLen, totalCount, totalErrorCount, totalUnexpectedResultCount ); 255 _printTotals(
256 keyLen, totalCount, totalErrorCount, totalUnexpectedResultCount);
233 print(''); 257 print('');
234 _printGroupHeader('Notifications', keyLen); 258 _printGroupHeader('Notifications', keyLen);
235 for (String tag in keys) { 259 for (String tag in keys) {
236 Measurement m = measurements[tag]; 260 Measurement m = measurements[tag];
237 if (m.notification) { 261 if (m.notification) {
238 m.printSummary(keyLen); 262 m.printSummary(keyLen);
239 } 263 }
240 } 264 }
241 /// TODO(danrubel) *** print warnings if driver caches are not empty **** 265 /// TODO(danrubel) *** print warnings if driver caches are not empty ****
242 print(''); 266 print('');
(...skipping 15 matching lines...) Expand all
258 } 282 }
259 measurement.record(success, elapsed); 283 measurement.record(success, elapsed);
260 } 284 }
261 285
262 void recordUnexpectedResults(String tag) { 286 void recordUnexpectedResults(String tag) {
263 measurements[tag].recordUnexpectedResults(); 287 measurements[tag].recordUnexpectedResults();
264 } 288 }
265 289
266 void _printGroupHeader(String groupName, int keyLen) { 290 void _printGroupHeader(String groupName, int keyLen) {
267 StringBuffer sb = new StringBuffer(); 291 StringBuffer sb = new StringBuffer();
268 _printColumn(sb, groupName, keyLen); 292 _printColumn(sb, groupName, keyLen);
269 _printColumn(sb, 'count', 6, rightJustified: true); 293 _printColumn(sb, 'count', 6, rightJustified: true);
270 _printColumn(sb, 'error', 6, rightJustified: true); 294 _printColumn(sb, 'error', 6, rightJustified: true);
271 _printColumn(sb, 'uxr(1)', 6, rightJustified: true); 295 _printColumn(sb, 'uxr(1)', 6, rightJustified: true);
272 sb.write(' '); 296 sb.write(' ');
273 _printColumn(sb, 'minimum', 15); 297 _printColumn(sb, 'mean', 15);
274 _printColumn(sb, 'average', 15); 298 _printColumn(sb, '90th', 15);
275 _printColumn(sb, 'maximum', 15); 299 _printColumn(sb, '99th', 15);
276 _printColumn(sb, 'total', 15); 300 _printColumn(sb, 'std-dev', 15);
277 print(sb.toString()); 301 _printColumn(sb, 'minimum', 15);
302 _printColumn(sb, 'maximum', 15);
303 _printColumn(sb, 'total', 15);
304 print(sb.toString());
278 } 305 }
279 306
280 void _printTotals(int keyLen, int totalCount, int totalErrorCount, int totalUn expectedResultCount) { 307 void _printTotals(int keyLen, int totalCount, int totalErrorCount,
308 int totalUnexpectedResultCount) {
281 StringBuffer sb = new StringBuffer(); 309 StringBuffer sb = new StringBuffer();
282 _printColumn(sb, 'Totals', keyLen); 310 _printColumn(sb, 'Totals', keyLen);
283 _printColumn(sb, totalCount.toString(), 6, rightJustified: true); 311 _printColumn(sb, totalCount.toString(), 6, rightJustified: true);
284 _printColumn(sb, totalErrorCount.toString(), 6, rightJustified: true); 312 _printColumn(sb, totalErrorCount.toString(), 6, rightJustified: true);
285 _printColumn(sb, totalUnexpectedResultCount.toString(), 6, 313 _printColumn(sb, totalUnexpectedResultCount.toString(), 6,
286 rightJustified: true); 314 rightJustified: true);
287 print(sb.toString()); 315 print(sb.toString());
288 } 316 }
289 } 317 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/integration/integration_tests.dart ('k') | pkg/analysis_server/test/performance/input_converter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698