Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import argparse | |
| 7 import importlib | |
| 8 import os | |
| 9 import subprocess | |
|
abarth-chromium
2014/11/14 04:44:13
Unused
yzshen1
2014/11/14 18:00:15
Done.
| |
| 10 import sys | |
| 11 | |
| 12 | |
| 13 class BenchmarkRunner(object): | |
| 14 def __init__(self, args): | |
| 15 self._args = args | |
| 16 self._benchmark_dir = os.path.dirname(os.path.realpath(__file__)) | |
| 17 | |
| 18 def _list_tests(self): | |
| 19 tests = [] | |
| 20 for name in os.listdir(self._benchmark_dir): | |
| 21 path = os.path.join(self._benchmark_dir, name) | |
| 22 if os.path.isdir(path): | |
| 23 tests.append(name) | |
| 24 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.
| |
| 25 | |
| 26 def _run_test(self, test_name): | |
| 27 print "Running %s ..." % test_name | |
| 28 run_script_path = os.path.join(self._benchmark_dir, test_name, 'run.py') | |
| 29 if os.path.isfile(run_script_path): | |
| 30 run_module = '.'.join([test_name, 'run']) | |
| 31 importlib.import_module(run_module) | |
| 32 result = sys.modules[run_module].run(self._args) | |
| 33 | |
| 34 #TODO(yzshen): (1) consider using more structured result; | |
| 35 # (2) upload the result to server. | |
| 36 print result | |
| 37 | |
| 38 def run(self): | |
| 39 tests = self._list_tests() | |
| 40 for test in tests: | |
| 41 self._run_test(test) | |
| 42 | |
| 43 | |
| 44 def main(): | |
| 45 parser = argparse.ArgumentParser( | |
| 46 description='Mojo performance benchmark runner') | |
| 47 | |
| 48 debug_group = parser.add_mutually_exclusive_group() | |
| 49 debug_group.add_argument('--release', | |
| 50 help='test against release build (default)', | |
| 51 default=True, action='store_true') | |
| 52 debug_group.add_argument('--debug', help='test against debug build', | |
| 53 default=False, dest='release', action='store_false') | |
| 54 | |
| 55 args = parser.parse_args() | |
| 56 | |
| 57 BenchmarkRunner(args).run() | |
| 58 | |
| 59 | |
| 60 if __name__ == '__main__': | |
| 61 sys.exit(main()) | |
| OLD | NEW |