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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/benchmark/perf/performance_tests.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/benchmark/perf/analysis_timing_tests.dart
diff --git a/pkg/analysis_server/benchmark/perf/analysis_timing_tests.dart b/pkg/analysis_server/benchmark/perf/analysis_timing_tests.dart
index fd50e1364040614ff0158e9da8141002c7754bcd..fd29981882f4b588a43e42e539cb56b19190987a 100644
--- a/pkg/analysis_server/benchmark/perf/analysis_timing_tests.dart
+++ b/pkg/analysis_server/benchmark/perf/analysis_timing_tests.dart
@@ -7,43 +7,76 @@ library server.performance.analysis.timing;
import 'dart:async';
import 'dart:io';
+import 'package:analysis_server/src/protocol.dart';
import 'package:args/args.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'package:unittest/unittest.dart';
import '../../test/utils.dart';
import 'performance_tests.dart';
-const String SOURCE_OPTION = 'source';
-
/**
- * Pass in the directory of the source to be analyzed as option --source
+ * Pass in the directory of the source to be analyzed as option `--source`,
+ * optionally specify a priority file with `--priority` and the specific
+ * test to run with `--test`. If no test is specified, the default is
+ * `analysis`.
*/
-main(List<String> arguements) {
+main(List<String> arguments) {
initializeTestEnvironment();
ArgParser parser = _createArgParser();
- var args = parser.parse(arguements);
+ var args = parser.parse(arguments);
if (args[SOURCE_OPTION] == null) {
print('path to source directory must be specified');
exit(1);
}
source = args[SOURCE_OPTION];
- defineReflectiveTests(AnalysisTimingIntegrationTest);
+ priorityFile = args[PRIORITY_FILE_OPTION];
+ testName = args[TEST_NAME_OPTION] ?? DEFAULT_TEST;
+
+ switch (testName) {
+ case 'analysis':
+ defineReflectiveTests(AnalysisTimingIntegrationTest);
+ break;
+ case 'navigation':
+ defineReflectiveTests(NavigationTimingIntegrationTest);
+ break;
+ default:
+ print('unrecognized test name $testName');
+ exit(1);
+ }
}
+const DEFAULT_TEST = 'analysis';
+const PRIORITY_FILE_OPTION = 'priority';
+const SOURCE_OPTION = 'source';
+const TEST_NAME_OPTION = 'test';
+
+String priorityFile;
String source;
+String testName;
+
+ArgParser _createArgParser() => new ArgParser()
+ ..addOption(TEST_NAME_OPTION, help: 'test name (defaults to `analysis`)')
+ ..addOption(SOURCE_OPTION, help: 'full path to source directory for analysis')
+ ..addOption(PRIORITY_FILE_OPTION,
+ help: '(optional) full path to a priority file');
+
+class AbstractTimingTest extends AbstractAnalysisServerPerformanceTest {
+ @override
+ Future setUp() => super.setUp().then((_) {
+ sourceDirectory = new Directory(source);
+ subscribeToStatusNotifications();
+ });
+}
@reflectiveTest
-class AnalysisTimingIntegrationTest
- extends AbstractAnalysisServerPerformanceTest {
+class AnalysisTimingIntegrationTest extends AbstractTimingTest {
test_detect_analysis_done() {
- sourceDirectory = new Directory(source);
- subscribeToStatusNotifications();
- return _runAndTimeAnalysis();
- }
-
- Future _runAndTimeAnalysis() {
stopwatch.start();
setAnalysisRoot();
+ if (priorityFile != null) {
+ sendAnalysisSetPriorityFiles([priorityFile]);
+ }
return analysisFinished.then((_) {
print('analysis completed in ${stopwatch.elapsed}');
stopwatch.reset();
@@ -51,9 +84,27 @@ class AnalysisTimingIntegrationTest
}
}
-ArgParser _createArgParser() {
- ArgParser parser = new ArgParser();
- parser.addOption('source',
- help: 'full path to source directory for analysis');
- return parser;
+@reflectiveTest
+class NavigationTimingIntegrationTest extends AbstractTimingTest {
+ Future test_detect_navigation_done() {
+ expect(priorityFile, isNotNull);
+ stopwatch.start();
+
+ Duration elapsed;
+ onAnalysisNavigation.listen((AnalysisNavigationParams params) {
+ elapsed = stopwatch.elapsed;
+ });
+
+ setAnalysisRoot();
+ sendAnalysisSetSubscriptions({
+ AnalysisService.NAVIGATION: [priorityFile]
+ });
+
+ sendAnalysisSetPriorityFiles([priorityFile]);
+
+ return analysisFinished.then((_) {
+ print('navigation completed in ${elapsed}');
+ stopwatch.reset();
+ });
+ }
}
« 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