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

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

Issue 1386003002: Benchmarking for navigation results. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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
« no previous file with comments | « no previous file | pkg/analysis_server/benchmark/perf/performance_tests.dart » ('j') | 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 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:analysis_server/src/protocol.dart';
10 import 'package:args/args.dart'; 11 import 'package:args/args.dart';
11 import 'package:test_reflective_loader/test_reflective_loader.dart'; 12 import 'package:test_reflective_loader/test_reflective_loader.dart';
13 import 'package:unittest/unittest.dart';
12 14
13 import '../../test/utils.dart'; 15 import '../../test/utils.dart';
14 import 'performance_tests.dart'; 16 import 'performance_tests.dart';
15 17
16 const String SOURCE_OPTION = 'source';
17
18 /** 18 /**
19 * Pass in the directory of the source to be analyzed as option --source 19 * Pass in the directory of the source to be analyzed as option `--source`,
20 * optionally specify a priority file with `--priority` and the specific
21 * test to run with `--test`. If no test is specified, the default is
22 * `analysis`.
20 */ 23 */
21 main(List<String> arguements) { 24 main(List<String> arguments) {
22 initializeTestEnvironment(); 25 initializeTestEnvironment();
23 ArgParser parser = _createArgParser(); 26 ArgParser parser = _createArgParser();
24 var args = parser.parse(arguements); 27 var args = parser.parse(arguments);
25 if (args[SOURCE_OPTION] == null) { 28 if (args[SOURCE_OPTION] == null) {
26 print('path to source directory must be specified'); 29 print('path to source directory must be specified');
27 exit(1); 30 exit(1);
28 } 31 }
29 source = args[SOURCE_OPTION]; 32 source = args[SOURCE_OPTION];
30 defineReflectiveTests(AnalysisTimingIntegrationTest); 33 priorityFile = args[PRIORITY_FILE_OPTION];
34 testName = args[TEST_NAME_OPTION] ?? DEFAULT_TEST;
35
36 switch (testName) {
37 case 'analysis':
38 defineReflectiveTests(AnalysisTimingIntegrationTest);
39 break;
40 case 'navigation':
41 defineReflectiveTests(NavigationTimingIntegrationTest);
42 break;
43 default:
44 print('unrecognized test name $testName');
45 exit(1);
46 }
31 } 47 }
32 48
49 const DEFAULT_TEST = 'analysis';
50 const PRIORITY_FILE_OPTION = 'priority';
51 const SOURCE_OPTION = 'source';
52 const TEST_NAME_OPTION = 'test';
53
54 String priorityFile;
33 String source; 55 String source;
56 String testName;
57
58 ArgParser _createArgParser() => new ArgParser()
59 ..addOption(TEST_NAME_OPTION, help: 'test name (defaults to `analysis`)')
60 ..addOption(SOURCE_OPTION, help: 'full path to source directory for analysis')
61 ..addOption(PRIORITY_FILE_OPTION,
62 help: '(optional) full path to a priority file');
63
64 class AbstractTimingTest extends AbstractAnalysisServerPerformanceTest {
65 @override
66 Future setUp() => super.setUp().then((_) {
67 sourceDirectory = new Directory(source);
68 subscribeToStatusNotifications();
69 });
70 }
34 71
35 @reflectiveTest 72 @reflectiveTest
36 class AnalysisTimingIntegrationTest 73 class AnalysisTimingIntegrationTest extends AbstractTimingTest {
37 extends AbstractAnalysisServerPerformanceTest {
38 test_detect_analysis_done() { 74 test_detect_analysis_done() {
39 sourceDirectory = new Directory(source);
40 subscribeToStatusNotifications();
41 return _runAndTimeAnalysis();
42 }
43
44 Future _runAndTimeAnalysis() {
45 stopwatch.start(); 75 stopwatch.start();
46 setAnalysisRoot(); 76 setAnalysisRoot();
77 if (priorityFile != null) {
78 sendAnalysisSetPriorityFiles([priorityFile]);
79 }
47 return analysisFinished.then((_) { 80 return analysisFinished.then((_) {
48 print('analysis completed in ${stopwatch.elapsed}'); 81 print('analysis completed in ${stopwatch.elapsed}');
49 stopwatch.reset(); 82 stopwatch.reset();
50 }); 83 });
51 } 84 }
52 } 85 }
53 86
54 ArgParser _createArgParser() { 87 @reflectiveTest
55 ArgParser parser = new ArgParser(); 88 class NavigationTimingIntegrationTest extends AbstractTimingTest {
56 parser.addOption('source', 89 Future test_detect_navigation_done() {
57 help: 'full path to source directory for analysis'); 90 expect(priorityFile, isNotNull);
58 return parser; 91 stopwatch.start();
92
93 Duration elapsed;
94 onAnalysisNavigation.listen((AnalysisNavigationParams params) {
95 elapsed = stopwatch.elapsed;
96 });
97
98 setAnalysisRoot();
99 sendAnalysisSetSubscriptions({
100 AnalysisService.NAVIGATION: [priorityFile]
101 });
102
103 sendAnalysisSetPriorityFiles([priorityFile]);
104
105 return analysisFinished.then((_) {
106 print('navigation completed in ${elapsed}');
107 stopwatch.reset();
108 });
109 }
59 } 110 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/benchmark/perf/performance_tests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698