Index: benchmarks/benchmark_runner.py |
diff --git a/benchmarks/benchmark_runner.py b/benchmarks/benchmark_runner.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..f12393d750d654a8696304eff95d327a26bc0dbb |
--- /dev/null |
+++ b/benchmarks/benchmark_runner.py |
@@ -0,0 +1,61 @@ |
+#!/usr/bin/env python |
+# Copyright 2014 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+import argparse |
+import importlib |
+import os |
+import subprocess |
abarth-chromium
2014/11/14 04:44:13
Unused
yzshen1
2014/11/14 18:00:15
Done.
|
+import sys |
+ |
+ |
+class BenchmarkRunner(object): |
+ def __init__(self, args): |
+ self._args = args |
+ self._benchmark_dir = os.path.dirname(os.path.realpath(__file__)) |
+ |
+ def _list_tests(self): |
+ tests = [] |
+ for name in os.listdir(self._benchmark_dir): |
+ path = os.path.join(self._benchmark_dir, name) |
+ if os.path.isdir(path): |
+ tests.append(name) |
+ return tests |
abarth-chromium
2014/11/14 04:44:13
I probably would have used a generator.
yzshen1
2014/11/14 18:00:15
Done.
|
+ |
+ def _run_test(self, test_name): |
+ print "Running %s ..." % test_name |
+ run_script_path = os.path.join(self._benchmark_dir, test_name, 'run.py') |
+ if os.path.isfile(run_script_path): |
+ run_module = '.'.join([test_name, 'run']) |
+ importlib.import_module(run_module) |
+ result = sys.modules[run_module].run(self._args) |
+ |
+ #TODO(yzshen): (1) consider using more structured result; |
+ # (2) upload the result to server. |
+ print result |
+ |
+ def run(self): |
+ tests = self._list_tests() |
+ for test in tests: |
+ self._run_test(test) |
+ |
+ |
+def main(): |
+ parser = argparse.ArgumentParser( |
+ description='Mojo performance benchmark runner') |
+ |
+ debug_group = parser.add_mutually_exclusive_group() |
+ debug_group.add_argument('--release', |
+ help='test against release build (default)', |
+ default=True, action='store_true') |
+ debug_group.add_argument('--debug', help='test against debug build', |
+ default=False, dest='release', action='store_false') |
+ |
+ args = parser.parse_args() |
+ |
+ BenchmarkRunner(args).run() |
+ |
+ |
+if __name__ == '__main__': |
+ sys.exit(main()) |