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

Unified Diff: pkg/analysis_server/test/performance/main.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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/performance/main.dart
diff --git a/pkg/analysis_server/test/performance/main.dart b/pkg/analysis_server/test/performance/main.dart
index 860487620e9138d09dc665d42a926654b987cd4e..9d085fc40d070e58c085a85d2bd2cbb1e0fde5de 100644
--- a/pkg/analysis_server/test/performance/main.dart
+++ b/pkg/analysis_server/test/performance/main.dart
@@ -1,3 +1,7 @@
+// 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';
@@ -12,6 +16,12 @@ import 'input_converter.dart';
import 'operation.dart';
/**
+ * The amount of time to give the server to respond to a shutdown request
+ * before forcibly terminating it.
+ */
+const Duration SHUTDOWN_TIMEOUT = const Duration(seconds: 25);
+
+/**
* Launch and interact with the analysis server.
*/
main(List<String> rawArgs) {
@@ -19,9 +29,9 @@ main(List<String> rawArgs) {
logger.onRecord.listen((LogRecord rec) {
print(rec.message);
});
- Driver driver = new Driver(logger);
-
ArgResults args = parseArgs(rawArgs);
+
+ Driver driver = new Driver(logger);
Stream<Operation> stream = openInput(args);
StreamSubscription<Operation> subscription;
subscription = stream.listen((Operation op) {
@@ -34,12 +44,11 @@ main(List<String> rawArgs) {
}
}, onDone: () {
subscription.cancel();
- driver.stopServer();
+ driver.stopServer(SHUTDOWN_TIMEOUT);
}, onError: (e, s) {
subscription.cancel();
- logger.log(Level.WARNING, '$e\n$s');
- driver.stopServer();
- throw e;
+ logger.log(Level.SEVERE, '$e\n$s');
+ driver.stopServer(SHUTDOWN_TIMEOUT);
});
driver.runComplete.then((Results results) {
results.printResults();
@@ -50,6 +59,8 @@ main(List<String> rawArgs) {
const HELP_CMDLINE_OPTION = 'help';
const INPUT_CMDLINE_OPTION = 'input';
+const MAP_FROM_OPTION = 'mapFrom';
+const MAP_TO_OPTION = 'mapTo';
const VERBOSE_CMDLINE_OPTION = 'verbose';
const VERY_VERBOSE_CMDLINE_OPTION = 'vv';
@@ -68,10 +79,18 @@ Stream<Operation> openInput(ArgResults args) {
} else {
inputRaw = new File(inputPath).openRead();
}
+ Map<String, String> srcPathMap = new Map<String, String>();
+ String mapFrom = args[MAP_FROM_OPTION];
+ if (mapFrom != null && mapFrom.isNotEmpty) {
+ String mapTo = args[MAP_TO_OPTION];
+ srcPathMap[mapFrom] = mapTo;
+ new Logger('openInput').log(
+ Level.INFO, 'mapping source paths\n from $mapFrom\n to $mapTo');
+ }
return inputRaw
.transform(SYSTEM_ENCODING.decoder)
.transform(new LineSplitter())
- .transform(new InputConverter());
+ .transform(new InputConverter(srcPathMap));
}
/**
@@ -85,6 +104,12 @@ ArgResults parseArgs(List<String> rawArgs) {
help: 'The input file specifying how this client should interact '
'with the server. If the input file name is "stdin", '
'then the instructions are read from standard input.');
+ parser.addOption(MAP_FROM_OPTION,
+ help: 'The original source directory when the instrumentation '
+ 'or log file was generated.');
+ parser.addOption(MAP_TO_OPTION,
+ help: 'The target source directory used during performance testing. '
+ 'WARNING: The contents of this directory will be modified');
parser.addFlag(VERBOSE_CMDLINE_OPTION,
abbr: 'v', help: 'Verbose logging', negatable: false);
parser.addFlag(VERY_VERBOSE_CMDLINE_OPTION,
@@ -92,15 +117,29 @@ ArgResults parseArgs(List<String> rawArgs) {
parser.addFlag(HELP_CMDLINE_OPTION,
abbr: 'h', help: 'Print this help information', negatable: false);
- ArgResults args = parser.parse(rawArgs);
+ ArgResults args;
+ try {
+ args = parser.parse(rawArgs);
+ } on Exception catch (e) {
+ print(e);
+ printHelp(parser);
+ exit(1);
+ }
+
bool showHelp = args[HELP_CMDLINE_OPTION] || args.rest.isNotEmpty;
- if (args[INPUT_CMDLINE_OPTION] == null ||
- args[INPUT_CMDLINE_OPTION].isEmpty) {
+ bool isMissing(key) => args[key] == null || args[key].isEmpty;
+
+ if (isMissing(INPUT_CMDLINE_OPTION)) {
print('missing "input" argument');
showHelp = true;
}
-
+
+ if (isMissing(MAP_FROM_OPTION) != isMissing(MAP_TO_OPTION)) {
+ print('must specifiy both $MAP_FROM_OPTION and $MAP_TO_OPTION');
+ showHelp = true;
+ }
+
if (args[VERY_VERBOSE_CMDLINE_OPTION] || rawArgs.contains('-vv')) {
Logger.root.level = Level.FINE;
} else if (args[VERBOSE_CMDLINE_OPTION]) {
@@ -110,11 +149,15 @@ ArgResults parseArgs(List<String> rawArgs) {
}
if (showHelp) {
- print('');
- print('Launch and interact with the AnalysisServer');
- print(parser.usage);
+ printHelp(parser);
exit(1);
}
return args;
}
+
+void printHelp(ArgParser parser) {
+ print('');
+ print('Launch and interact with the AnalysisServer');
+ print(parser.usage);
+}

Powered by Google App Engine
This is Rietveld 408576698