blob: 05c3a191eb5f845ac450b0734ecb4cd475d1aea6 [file] [log] [blame]
Johnny Cheneef90572011-10-22 00:57:05 +00001#!/usr/bin/env python
2
3"""
4A simple bench runner which delegates to the ./dotest.py test driver to run the
5benchmarks defined in the list named 'benches'.
6
7You need to hand edit 'benches' to modify/change the command lines passed to the
8test driver.
9
10Use the following to get only the benchmark results in your terminal output:
11
Johnny Chenebbec4c2011-10-26 22:58:02 +000012 ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:'
13
14See also bench-history.
Johnny Cheneef90572011-10-22 00:57:05 +000015"""
16
17import os, sys
18import re
Johnny Chenebbec4c2011-10-26 22:58:02 +000019from optparse import OptionParser
Johnny Cheneef90572011-10-22 00:57:05 +000020
21# dotest.py invocation with no '-e exe-path' uses lldb as the inferior program,
22# unless there is a mentioning of custom executable program.
23benches = [
Johnny Chenebbec4c2011-10-26 22:58:02 +000024 # Measure startup delays creating a target, setting a breakpoint, and run to breakpoint stop.
25 './dotest.py -v +b %E %X -n -p TestStartupDelays.py',
Johnny Cheneef90572011-10-22 00:57:05 +000026
Johnny Chenebbec4c2011-10-26 22:58:02 +000027 # Measure 'frame variable' response after stopping at a breakpoint.
28 './dotest.py -v +b %E %X -n -p TestFrameVariableResponse.py',
Johnny Cheneef90572011-10-22 00:57:05 +000029
Johnny Chenebbec4c2011-10-26 22:58:02 +000030 # Measure stepping speed after stopping at a breakpoint.
31 './dotest.py -v +b %E %X -n -p TestSteppingSpeed.py',
Johnny Cheneef90572011-10-22 00:57:05 +000032
33 # Measure expression cmd response with a simple custom executable program.
34 './dotest.py +b -n -p TestExpressionCmd.py',
35
Johnny Chenebbec4c2011-10-26 22:58:02 +000036 # Attach to a spawned process then run disassembly benchmarks.
37 './dotest.py -v +b -n %E -p TestDoAttachThenDisassembly.py'
Johnny Cheneef90572011-10-22 00:57:05 +000038]
39
40def main():
41 """Read the items from 'benches' and run the command line one by one."""
Johnny Chenebbec4c2011-10-26 22:58:02 +000042 parser = OptionParser(usage="""\
43%prog [options]
44Run the standard benchmarks defined in the list named 'benches'.\
45""")
46 parser.add_option('-e', '--executable',
47 type='string', action='store',
48 dest='exe',
49 help='The target program launched by lldb.')
50 parser.add_option('-x', '--breakpoint-spec',
51 type='string', action='store',
52 dest='break_spec',
53 help='The lldb breakpoint spec for the target program.')
54
55 # Parses the options, if any.
56 opts, args = parser.parse_args()
57
Johnny Cheneef90572011-10-22 00:57:05 +000058 print "Starting bench runner...."
59
Johnny Chenebbec4c2011-10-26 22:58:02 +000060 for item in benches:
61 command = item.replace('%E',
62 '-e "%s"' % opts.exe if opts.exe else '')
63 command = command.replace('%X',
64 '-x "%s"' % opts.break_spec if opts.break_spec else '')
Johnny Cheneef90572011-10-22 00:57:05 +000065 print "Running %s" % (command)
66 os.system(command)
67
68 print "Bench runner done."
69
70if __name__ == '__main__':
71 main()