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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « benchmarks/DEPS ('k') | benchmarks/startup/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 imp
8 import importlib
9 import os
10 import sys
11
12 try:
13 imp.find_module('mopy')
14 except ImportError:
15 sys.path.append(os.path.abspath(os.path.join(
16 __file__, os.pardir, os.pardir, 'mojo', 'tools')))
17 from mopy.paths import Paths
18
19
20 class BenchmarkRunner(object):
21 def __init__(self, args):
22 self._args = args
23 self._benchmark_dir = os.path.dirname(os.path.realpath(__file__))
24 if args.release:
25 build_directory = os.path.join('out', 'Release')
26 else:
27 build_directory = os.path.join('out', 'Debug')
28 self._paths = Paths(build_directory)
29
30 def _list_tests(self):
31 for name in os.listdir(self._benchmark_dir):
32 path = os.path.join(self._benchmark_dir, name)
33 if os.path.isdir(path):
34 yield name
35
36 def _run_test(self, test_name):
37 print "Running %s ..." % test_name
38 run_script_path = os.path.join(self._benchmark_dir, test_name, 'run.py')
39 if os.path.isfile(run_script_path):
40 run_module = '.'.join([test_name, 'run'])
41 importlib.import_module(run_module)
42 result = sys.modules[run_module].run(self._args, self._paths)
43
44 #TODO(yzshen): (1) consider using more structured result;
45 # (2) upload the result to server.
46 print result
47
48 def run(self):
49 for test in self._list_tests():
50 self._run_test(test)
51
52
53 def main():
54 parser = argparse.ArgumentParser(
55 description='Mojo performance benchmark runner')
56
57 debug_group = parser.add_mutually_exclusive_group()
58 debug_group.add_argument('--release',
59 help='test against release build (default)',
60 default=True, action='store_true')
61 debug_group.add_argument('--debug', help='test against debug build',
62 default=False, dest='release', action='store_false')
63
64 args = parser.parse_args()
65
66 BenchmarkRunner(args).run()
67
68
69 if __name__ == '__main__':
70 sys.exit(main())
OLDNEW
« 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