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

Side by Side Diff: pkg/analysis_server/benchmark/perf/completion_timing_tests.dart

Issue 1419503002: refactor timing tests to not use the test framework (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: remove unused code Created 5 years, 2 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.performance.analysis.timing; 5 library server.performance.analysis.timing;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:args/args.dart'; 10 import 'package:args/args.dart';
11 import 'package:test_reflective_loader/test_reflective_loader.dart';
12 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
13 12
14 import '../../test/utils.dart'; 13 import '../../test/utils.dart';
15 import 'performance_tests.dart'; 14 import 'performance_tests.dart';
16 15
17 /** 16 /**
18 * Pass in the directory of the source to be analyzed as option `--source`, 17 * Pass in the directory of the source to be analyzed as option `--source`,
19 * specify a priority file with `--priority` and an offset for completions 18 * specify a priority file with `--priority` and an offset for completions
20 * with a `--offset`. 19 * with a `--offset`.
21 */ 20 */
22 main(List<String> arguments) { 21 main(List<String> arguments) {
23 initializeTestEnvironment(); 22 initializeTestEnvironment();
24 ArgParser parser = _createArgParser(); 23 ArgParser parser = _createArgParser();
25 var args = parser.parse(arguments); 24 var args = parser.parse(arguments);
26 if (args[SOURCE_OPTION] == null) { 25 if (args[SOURCE_OPTION] == null) {
27 print('path to source directory must be specified'); 26 print('path to source directory must be specified');
28 exit(1); 27 exit(1);
29 } 28 }
30 source = args[SOURCE_OPTION]; 29 source = args[SOURCE_OPTION];
31 priorityFile = args[PRIORITY_FILE_OPTION]; 30 priorityFile = args[PRIORITY_FILE_OPTION];
32 offset = args[COMPLETION_OFFSET]; 31 offset = int.parse(args[COMPLETION_OFFSET]);
33 32
34 unittestConfiguration.timeout = new Duration(minutes: 20); 33 Future.wait([new CompletionTimingTest().test_timing()]);
35
36 defineReflectiveTests(CompletionTimingTest);
37 } 34 }
38 35
39 const PRIORITY_FILE_OPTION = 'priority'; 36 const PRIORITY_FILE_OPTION = 'priority';
40 const SOURCE_OPTION = 'source'; 37 const SOURCE_OPTION = 'source';
41 const COMPLETION_OFFSET = 'offset'; 38 const COMPLETION_OFFSET = 'offset';
42 39
43 String priorityFile; 40 String priorityFile;
44 String source; 41 String source;
45 int offset; 42 int offset;
46 43
47 ArgParser _createArgParser() => new ArgParser() 44 ArgParser _createArgParser() => new ArgParser()
48 ..addOption(SOURCE_OPTION, help: 'full path to source directory for analysis') 45 ..addOption(SOURCE_OPTION, help: 'full path to source directory for analysis')
49 ..addOption(PRIORITY_FILE_OPTION, help: 'full path to a priority file') 46 ..addOption(PRIORITY_FILE_OPTION, help: 'full path to a priority file')
50 ..addOption(COMPLETION_OFFSET, help: 'offset in file for code completions'); 47 ..addOption(COMPLETION_OFFSET, help: 'offset in file for code completions');
51 48
52 @reflectiveTest 49 /**
53 class CompletionTimingTest extends AbstractAnalysisServerPerformanceTest { 50 * CompletionTimingTest measures the time taken for the analysis server to respo nd with
51 * completion suggestions for a given file and offset. The time measured starts when
52 * the analysis root is set and is done when the completion suggestions are rece ived
53 * from the server. The test does not wait for analysis to be complete before as king for
54 * completions.
55 */
56 class CompletionTimingTest extends AbstractTimingTest {
54 List<Duration> timings = <Duration>[]; 57 List<Duration> timings = <Duration>[];
55 58
56 @override 59 Future test_timing() async {
57 Future setUp() => super.setUp().then((_) {
58 sourceDirectory = new Directory(source);
59 subscribeToStatusNotifications();
60 });
61
62 Future test_timing() {
63 // debugStdio(); 60 // debugStdio();
64 61
65 expect(priorityFile, isNotNull, 62 expect(priorityFile, isNotNull,
66 reason: 'A priority file must be specified for completion testing.'); 63 reason: 'A priority file must be specified for completion testing.');
67 expect(offset, isNotNull, 64 expect(offset, isNotNull,
68 reason: 'An offset must be specified for completion testing.'); 65 reason: 'An offset must be specified for completion testing.');
69 66
67 await init(source);
70 stopwatch.start(); 68 stopwatch.start();
71 69
72 onCompletionResults.listen((_) { 70 onCompletionResults.listen((_) {
73 timings.add(new Duration(milliseconds: stopwatch.elapsed.inMilliseconds)); 71 timings.add(new Duration(milliseconds: stopwatch.elapsed.inMilliseconds));
74 }); 72 });
75 73
76 setAnalysisRoot(); 74 setAnalysisRoot();
77 sendAnalysisSetPriorityFiles([priorityFile]); 75 sendAnalysisSetPriorityFiles([priorityFile]);
78 sendCompletionGetSuggestions(priorityFile, offset); 76 sendCompletionGetSuggestions(priorityFile, offset);
79 77
80 return analysisFinished.then((_) { 78 await analysisFinished;
81 print('analysis completed in ${stopwatch.elapsed}'); 79
82 timings.forEach((timing) => print('notification at : ${timings}')); 80 print('analysis completed in ${stopwatch.elapsed}');
83 stopwatch.reset(); 81 print('completion received at : ${timings}');
84 }); 82 await shutdown();
85 } 83 }
86 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698