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

Unified Diff: benchmarks/benchmark_runner.py

Issue 724243002: Add a startup benchmark and rudimentary scripts for running benchmarks. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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: 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())
« no previous file with comments | « benchmarks/DEPS ('k') | benchmarks/startup/BUILD.gn » ('j') | benchmarks/startup/run.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698