blob: ce9c2e75d7116f285a23526e495cb1f4ccb85711 [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
Zachary Turnerc1b7cd72015-11-05 19:22:28 +000018from __future__ import absolute_import
Zachary Turnerff890da2015-10-19 23:45:41 +000019
Johnny Chenb8da4262011-10-22 00:57:05 +000020import os, sys
21import re
Johnny Chen66d362e2011-10-26 22:58:02 +000022from optparse import OptionParser
Johnny Chenb8da4262011-10-22 00:57:05 +000023
24# dotest.py invocation with no '-e exe-path' uses lldb as the inferior program,
25# unless there is a mentioning of custom executable program.
26benches = [
Johnny Chen66d362e2011-10-26 22:58:02 +000027 # Measure startup delays creating a target, setting a breakpoint, and run to breakpoint stop.
28 './dotest.py -v +b %E %X -n -p TestStartupDelays.py',
Johnny Chenb8da4262011-10-22 00:57:05 +000029
Johnny Chen66d362e2011-10-26 22:58:02 +000030 # Measure 'frame variable' response after stopping at a breakpoint.
31 './dotest.py -v +b %E %X -n -p TestFrameVariableResponse.py',
Johnny Chenb8da4262011-10-22 00:57:05 +000032
Johnny Chen66d362e2011-10-26 22:58:02 +000033 # Measure stepping speed after stopping at a breakpoint.
34 './dotest.py -v +b %E %X -n -p TestSteppingSpeed.py',
Johnny Chenb8da4262011-10-22 00:57:05 +000035
36 # Measure expression cmd response with a simple custom executable program.
37 './dotest.py +b -n -p TestExpressionCmd.py',
38
Johnny Chen66d362e2011-10-26 22:58:02 +000039 # Attach to a spawned process then run disassembly benchmarks.
40 './dotest.py -v +b -n %E -p TestDoAttachThenDisassembly.py'
Johnny Chenb8da4262011-10-22 00:57:05 +000041]
42
43def main():
44 """Read the items from 'benches' and run the command line one by one."""
Johnny Chen66d362e2011-10-26 22:58:02 +000045 parser = OptionParser(usage="""\
46%prog [options]
47Run the standard benchmarks defined in the list named 'benches'.\
48""")
49 parser.add_option('-e', '--executable',
50 type='string', action='store',
51 dest='exe',
52 help='The target program launched by lldb.')
53 parser.add_option('-x', '--breakpoint-spec',
54 type='string', action='store',
55 dest='break_spec',
56 help='The lldb breakpoint spec for the target program.')
57
58 # Parses the options, if any.
59 opts, args = parser.parse_args()
60
Zachary Turnerff890da2015-10-19 23:45:41 +000061 print("Starting bench runner....")
Johnny Chenb8da4262011-10-22 00:57:05 +000062
Johnny Chen66d362e2011-10-26 22:58:02 +000063 for item in benches:
64 command = item.replace('%E',
65 '-e "%s"' % opts.exe if opts.exe else '')
66 command = command.replace('%X',
67 '-x "%s"' % opts.break_spec if opts.break_spec else '')
Zachary Turnerff890da2015-10-19 23:45:41 +000068 print("Running %s" % (command))
Johnny Chenb8da4262011-10-22 00:57:05 +000069 os.system(command)
70
Zachary Turnerff890da2015-10-19 23:45:41 +000071 print("Bench runner done.")
Johnny Chenb8da4262011-10-22 00:57:05 +000072
73if __name__ == '__main__':
74 main()