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

Unified Diff: pkg/analysis_server/benchmark/perf/performance_tests.dart

Issue 1366923003: add performance tests (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: move tests to benchmark Created 5 years, 3 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
Index: pkg/analysis_server/benchmark/perf/performance_tests.dart
diff --git a/pkg/analysis_server/benchmark/perf/performance_tests.dart b/pkg/analysis_server/benchmark/perf/performance_tests.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a926e33c98dedb9cc5cd2c63a46e42fac95bc57d
--- /dev/null
+++ b/pkg/analysis_server/benchmark/perf/performance_tests.dart
@@ -0,0 +1,75 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library server.performance;
+
+import 'dart:async';
+
+import 'package:analysis_server/src/protocol.dart';
+import 'package:unittest/unittest.dart';
+
+import '../../test/integration/integration_tests.dart';
+
+/**
+ * Base class for analysis server performance tests.
+ */
+abstract class AbstractAnalysisServerPerformanceTest
+ extends AbstractAnalysisServerIntegrationTest {
+ /**
+ * Stopwatch for timing results;
+ */
+ Stopwatch stopwatch = new Stopwatch();
+
+ /**
+ * Send the server an 'analysis.setAnalysisRoots' command directing it to
+ * analyze [sourceDirectory].
+ */
+ Future setAnalysisRoot() {
+ return sendAnalysisSetAnalysisRoots([sourceDirectory.path], []);
+ }
+
+ /**
+ * Enable [SERVER_STATUS] notifications so that [analysisFinished]
+ * can be used.
+ */
+ Future subscribeToStatusNotifications() {
+ List<Future> futures = <Future>[];
+ futures.add(sendServerSetSubscriptions([ServerService.STATUS]));
+ return Future.wait(futures);
+ }
+
+ /**
+ * The server is automatically started before every test.
+ */
+ @override
+ Future setUp() {
+ onAnalysisErrors.listen((AnalysisErrorsParams params) {
+ currentAnalysisErrors[params.file] = params.errors;
+ });
+ onServerError.listen((ServerErrorParams params) {
+ // A server error should never happen during an integration test.
+ fail('${params.message}\n${params.stackTrace}');
+ });
+ Completer serverConnected = new Completer();
+ onServerConnected.listen((_) {
+ expect(serverConnected.isCompleted, isFalse);
+ serverConnected.complete();
+ });
+ return startServer().then((_) {
+ server.listenToOutput(dispatchNotification);
+ server.exitCode.then((_) {
+ skipShutdown = true;
+ });
+ return serverConnected.future;
+ });
+ }
+
+ /**
+ * After every test, the server is stopped.
+ */
+ @override
+ Future tearDown() {
+ return shutdownIfNeeded();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698