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

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
« no previous file with comments | « benchmarks/DEPS ('k') | benchmarks/startup/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: benchmarks/benchmark_runner.py
diff --git a/benchmarks/benchmark_runner.py b/benchmarks/benchmark_runner.py
new file mode 100755
index 0000000000000000000000000000000000000000..590ab25acf0327e8e78ada34a54a8a2bb36a87ea
--- /dev/null
+++ b/benchmarks/benchmark_runner.py
@@ -0,0 +1,70 @@
+#!/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 imp
+import importlib
+import os
+import sys
+
+try:
+ imp.find_module('mopy')
+except ImportError:
+ sys.path.append(os.path.abspath(os.path.join(
+ __file__, os.pardir, os.pardir, 'mojo', 'tools')))
+from mopy.paths import Paths
+
+
+class BenchmarkRunner(object):
+ def __init__(self, args):
+ self._args = args
+ self._benchmark_dir = os.path.dirname(os.path.realpath(__file__))
+ if args.release:
+ build_directory = os.path.join('out', 'Release')
+ else:
+ build_directory = os.path.join('out', 'Debug')
+ self._paths = Paths(build_directory)
+
+ def _list_tests(self):
+ for name in os.listdir(self._benchmark_dir):
+ path = os.path.join(self._benchmark_dir, name)
+ if os.path.isdir(path):
+ yield name
+
+ 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, self._paths)
+
+ #TODO(yzshen): (1) consider using more structured result;
+ # (2) upload the result to server.
+ print result
+
+ def run(self):
+ for test in self._list_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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698