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

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

Issue 1182933005: analysis server performance measurement - work in progress (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments 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 | « pkg/analysis_server/test/performance/main.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) 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
3 // BSD-style license that can be found in the LICENSE file.
4
1 library server.operation; 5 library server.operation;
2 6
3 import 'dart:async'; 7 import 'dart:async';
4 8
5 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
6 import 'package:logging/logging.dart'; 10 import 'package:logging/logging.dart';
7 11
8 import 'driver.dart'; 12 import 'driver.dart';
9 13 import 'input_converter.dart';
10 class InfoOperation extends Operation {
11 final String message;
12
13 InfoOperation(this.message);
14
15 @override
16 Future perform(Driver driver) {
17 driver.logger.log(Level.INFO, message);
18 return null;
19 }
20 }
21 14
22 /** 15 /**
23 * An [Operation] represents an action such as sending a request to the server. 16 * An [Operation] represents an action such as sending a request to the server.
24 */ 17 */
25 abstract class Operation { 18 abstract class Operation {
26 Future perform(Driver driver); 19 Future perform(Driver driver);
27 } 20 }
28 21
29 /** 22 /**
30 * A [RequestOperation] sends a [JSON] request to the server. 23 * A [RequestOperation] sends a [JSON] request to the server.
31 */ 24 */
32 class RequestOperation extends Operation { 25 class RequestOperation extends Operation {
26 final CommonInputConverter converter;
33 final Map<String, dynamic> json; 27 final Map<String, dynamic> json;
34 28
35 RequestOperation(this.json); 29 RequestOperation(this.converter, this.json);
36 30
37 @override 31 @override
38 Future perform(Driver driver) { 32 Future perform(Driver driver) {
33 Stopwatch stopwatch = new Stopwatch();
39 String method = json['method']; 34 String method = json['method'];
40 driver.logger.log(Level.FINE, 'Sending request: $method\n $json'); 35 driver.logger.log(Level.FINE, 'Sending request: $method\n $json');
36 stopwatch.start();
37 void recordResponse(bool success, response) {
38 stopwatch.stop();
39 Duration elapsed = stopwatch.elapsed;
40 driver.results.record(method, elapsed, success: success);
41 driver.logger.log(
42 Level.FINE, 'Response received: $method : $elapsed\n $response');
43 }
41 driver.send(method, json['params']).then((response) { 44 driver.send(method, json['params']).then((response) {
42 driver.logger.log(Level.FINE, 'Response received: $method : $response'); 45 recordResponse(true, response);
43 }).catchError((e, s) { 46 }).catchError((e, s) {
44 driver.logger.log(Level.WARNING, 'Request failed: $method\n $e\n$s'); 47 recordResponse(false, e);
45 throw 'Send request failed: $e'; 48 converter.recordErrorResponse(json, e);
46 }); 49 });
47 return null; 50 return null;
48 } 51 }
49 } 52 }
50 53
51 class StartServerOperation extends Operation { 54 class StartServerOperation extends Operation {
52 @override 55 @override
53 Future perform(Driver driver) { 56 Future perform(Driver driver) {
54 return driver.startServer(); 57 return driver.startServer();
55 } 58 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 subscription.cancel(); 99 subscription.cancel();
97 timer.cancel(); 100 timer.cancel();
98 String message = 'gave up waiting for analysis to complete'; 101 String message = 'gave up waiting for analysis to complete';
99 driver.logger.log(Level.WARNING, message); 102 driver.logger.log(Level.WARNING, message);
100 completer.completeError(message); 103 completer.completeError(message);
101 } 104 }
102 }); 105 });
103 return completer.future; 106 return completer.future;
104 } 107 }
105 } 108 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/performance/main.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698