summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorCraig Silverstein <csilvers@khanacademy.org>2008-05-20 05:58:25 +0000
committerCraig Silverstein <csilvers@khanacademy.org>2008-05-20 05:58:25 +0000
commit48fff1e2284aed7ea44eb6ac23b00166c1225038 (patch)
tree655e2808f97be300ad244ded5297f3e396f2b92d /bench
parent9268767b63b4ffeb6180be675e4735c4161c1614 (diff)
downloaddistcc-git-48fff1e2284aed7ea44eb6ac23b00166c1225038.tar.gz
Add --output to benchmark.py, to print the final timing summary to a
file in addition to stdout. Also made sure we don't try to access opt_cc and opt_cxx until after all flags are read, so flag order doesn't matter. Finally, fixed indentation so we only print the default actions when --help is specified (as intended). Tested by running make benchmark. Reviewed by klarlund@google.com
Diffstat (limited to 'bench')
-rwxr-xr-xbench/benchmark.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/bench/benchmark.py b/bench/benchmark.py
index 21e935d..57edd7a 100755
--- a/bench/benchmark.py
+++ b/bench/benchmark.py
@@ -47,10 +47,6 @@
# TODO: Allow choice of which compiler and make options to use.
-# TODO: Try building something large in C++.
-
-# TODO: Set CXX as well.
-
# TODO: Add option to run tests repeatedly and show mean and std. dev.
# TODO: Perhaps add option to do "make clean" -- this might be faster
@@ -113,6 +109,7 @@ Options:
--list-projects show defined projects
--cc=PATH specify base value of CC to pass to configure
--cxx=PATH specify base value of CXX to pass to configure
+ --output=FILE print final summary to FILE in addition to stdout
-c, --compiler=COMPILER specify one compiler to use; format is
{local|dist|lzo|pump},h<NUMHOSTS>,j<NUMJOBS>
-n N repeat compilation N times
@@ -133,7 +130,7 @@ Multiple -c/--compiler options specify different scenarios to measure.
The default is to measure a few reasonable scenarios.
"""
-actions.action_help()
+ actions.action_help()
# -a is for developer use only and not documented; unless you're
@@ -148,11 +145,12 @@ def main():
sum = Summary()
options, args = getopt(sys.argv[1:], 'a:c:n:',
['list-projects', 'actions=', 'help', 'compiler=',
- 'cc=', 'cxx='])
+ 'cc=', 'cxx=', 'output='])
opt_actions = actions.default_actions
opt_cc = 'cc'
opt_cxx = 'cxx'
- set_compilers = []
+ opt_output = None
+ opt_compilers = []
opt_repeats = 1
for opt, optarg in options:
@@ -168,14 +166,17 @@ def main():
opt_cc = optarg
elif opt == '--cxx':
opt_cxx = optarg
+ elif opt == '--output':
+ opt_output = optarg
elif opt == '--compiler' or opt == '-c':
- set_compilers.append(compiler.parse_compiler_opt(optarg,
- cc=opt_cc,
- cxx=opt_cxx))
+ opt_compilers.append(optarg)
elif opt == '-n':
opt_repeats = int(optarg)
- if not set_compilers:
+ if opt_compilers:
+ set_compilers = [compiler.parse_compiler_opt(c, cc=opt_cc, cxx=opt_cxx)
+ for c in opt_compilers]
+ else:
set_compilers = compiler.default_compilers(cc=opt_cc, cxx=opt_cxx)
# Find named projects, or run all by default
@@ -191,6 +192,15 @@ def main():
build.build_actions(opt_actions, sum)
sum.print_table()
+ # If --output was specified, print the table to the output-file too
+ if opt_output:
+ old_stdout = sys.stdout
+ sys.stdout = open(opt_output, 'w')
+ try:
+ sum.print_table()
+ finally:
+ sys.stdout.close()
+ sys.stdout = old_stdout
if __name__ == '__main__':
main()