blob: 664aa3a93b817af68d2ec6651e3a9f1100ae5d15 [file] [log] [blame]
Johnny Chenb8da4262011-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 Chen66d362e2011-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 Chenb8da4262011-10-22 00:57:05 +000015"""
16
Zachary Turnerff890da2015-10-19 23:45:41 +000017from __future__ import print_function
18
Johnny Chenb8da4262011-10-22 00:57:05 +000019import os, sys
20import re
Johnny Chen66d362e2011-10-26 22:58:02 +000021from optparse import OptionParser
Johnny Chenb8da4262011-10-22 00:57:05 +000022
23# dotest.py invocation with no '-e exe-path' uses lldb as the inferior program,
24# unless there is a mentioning of custom executable program.
25benches = [
Johnny Chen66d362e2011-10-26 22:58:02 +000026 # Measure startup delays creating a target, setting a breakpoint, and run to breakpoint stop.
27 './dotest.py -v +b %E %X -n -p TestStartupDelays.py',
Johnny Chenb8da4262011-10-22 00:57:05 +000028
Johnny Chen66d362e2011-10-26 22:58:02 +000029 # Measure 'frame variable' response after stopping at a breakpoint.
30 './dotest.py -v +b %E %X -n -p TestFrameVariableResponse.py',
Johnny Chenb8da4262011-10-22 00:57:05 +000031
Johnny Chen66d362e2011-10-26 22:58:02 +000032 # Measure stepping speed after stopping at a breakpoint.
33 './dotest.py -v +b %E %X -n -p TestSteppingSpeed.py',
Johnny Chenb8da4262011-10-22 00:57:05 +000034
35 # Measure expression cmd response with a simple custom executable program.
36 './dotest.py +b -n -p TestExpressionCmd.py',
37
Johnny Chen66d362e2011-10-26 22:58:02 +000038 # Attach to a spawned process then run disassembly benchmarks.
39 './dotest.py -v +b -n %E -p TestDoAttachThenDisassembly.py'
Johnny Chenb8da4262011-10-22 00:57:05 +000040]
41
42def main():
43 """Read the items from 'benches' and run the command line one by one."""
Johnny Chen66d362e2011-10-26 22:58:02 +000044 parser = OptionParser(usage="""\
45%prog [options]
46Run the standard benchmarks defined in the list named 'benches'.\
47""")
48 parser.add_option('-e', '--executable',
49 type='string', action='store',
50 dest='exe',
51 help='The target program launched by lldb.')
52 parser.add_option('-x', '--breakpoint-spec',
53 type='string', action='store',
54 dest='break_spec',
55 help='The lldb breakpoint spec for the target program.')
56
57 # Parses the options, if any.
58 opts, args = parser.parse_args()
59
Zachary Turnerff890da2015-10-19 23:45:41 +000060 print("Starting bench runner....")
Johnny Chenb8da4262011-10-22 00:57:05 +000061
Johnny Chen66d362e2011-10-26 22:58:02 +000062 for item in benches:
63 command = item.replace('%E',
64 '-e "%s"' % opts.exe if opts.exe else '')
65 command = command.replace('%X',
66 '-x "%s"' % opts.break_spec if opts.break_spec else '')
Zachary Turnerff890da2015-10-19 23:45:41 +000067 print("Running %s" % (command))
Johnny Chenb8da4262011-10-22 00:57:05 +000068 os.system(command)
69
Zachary Turnerff890da2015-10-19 23:45:41 +000070 print("Bench runner done.")
Johnny Chenb8da4262011-10-22 00:57:05 +000071
72if __name__ == '__main__':
73 main()