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

Unified Diff: pkg/analysis_server/test/performance/local_runner.dart

Issue 1182933005: analysis server performance measurement - work in progress (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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/local_runner.dart
diff --git a/pkg/analysis_server/test/performance/local_runner.dart b/pkg/analysis_server/test/performance/local_runner.dart
new file mode 100644
index 0000000000000000000000000000000000000000..120627baddb8159394da6f2d9c85ca6a134e6468
--- /dev/null
+++ b/pkg/analysis_server/test/performance/local_runner.dart
@@ -0,0 +1,86 @@
+// 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.
+
+import 'dart:io';
+import 'package:path/path.dart';
+import 'main.dart' as performance;
+
+// Local driver for performance measurement
+
+main(List<String> args) {
+ /*
+ * Parse arguments
+ */
+ if (args.length != 3) printHelp('Expected 3 arguments');
+ var gitDir = new Directory(args[0]);
+ if (!gitDir.existsSync()) printHelp('${gitDir.path} does not exist');
+ if (!new Directory(join(gitDir.path, '.git')).existsSync()) printHelp(
+ '${gitDir.path} does not appear to be a local git repository');
+ var branch = args[1];
+ var inputFile = new File(args[2]);
+ if (!inputFile.existsSync()) printHelp('${inputFile.path} does not exist');
+ /*
+ * Create a new temp directory
+ */
+ var tmpDir = new Directory(
+ join(Directory.systemTemp.path, 'analysis_server_perf_target'));
+ if (!tmpDir.path.contains('tmp')) throw 'invalid tmp directory\n $tmpDir';
+ print('Extracting target analysis environment into\n ${tmpDir.path}');
+ if (tmpDir.existsSync()) tmpDir.deleteSync(recursive: true);
+ tmpDir.createSync(recursive: true);
+ /*
+ * Setup the initial target source in the temp directory
+ */
+ var tarFilePath = join(tmpDir.path, 'targetSrc.tar');
+ var result = Process.runSync('git', ['archive', branch, '-o', tarFilePath],
+ workingDirectory: gitDir.path);
+ if (result.exitCode != 0) throw 'failed to obtain target source: $result';
+ var tmpSrcDirPath = join(tmpDir.path, 'targetSrc');
+ new Directory(tmpSrcDirPath).createSync();
+ result = Process.runSync('tar', ['-xf', tarFilePath],
+ workingDirectory: tmpSrcDirPath);
+ if (result.exitCode != 0) throw 'failed to extract target source: $result';
+ /*
+ * Symlink the out or xcodebuild directory
+ */
+ var outDirName = 'out';
+ if (!new Directory(join(gitDir.path, outDirName)).existsSync()) {
+ outDirName = 'xcodebuild';
+ }
+ if (!new Directory(join(gitDir.path, outDirName)).existsSync()) {
+ throw 'failed to find out or xcodebuild directory';
+ }
+ result = Process.runSync('ln', [
+ '-s',
+ join(gitDir.path, outDirName),
+ join(tmpSrcDirPath, outDirName)
+ ]);
+ if (result.exitCode != 0) throw 'failed to link out or xcodebuild: $result';
+ /*
+ * Launch the performance analysis tool
+ */
+ performance.main([
+ //'-vv', // very verbose
+ '-i',
+ inputFile.path,
+ '--mapFrom',
+ gitDir.path,
+ '--mapTo',
+ tmpSrcDirPath
+ ]);
+}
+
+/// Print help and exit
+void printHelp([String errMsg]) {
+ if (errMsg != null) {
+ print('');
+ print('Error: $errMsg');
+ print('');
+ }
+ print('Arguments: <gitDir> <branch> <inputFile>');
+ print('gitDir = git repository containing the initial target source');
+ print('branch = the branch containing the initial target source');
+ print('inputFile = the instrumentation or log file');
+ exit(1);
+}

Powered by Google App Engine
This is Rietveld 408576698