Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | """ |
| 4 | A simple bench runner which delegates to the ./dotest.py test driver to run the |
| 5 | benchmarks defined in the list named 'benches'. |
| 6 | |
| 7 | You need to hand edit 'benches' to modify/change the command lines passed to the |
| 8 | test driver. |
| 9 | |
| 10 | Use the following to get only the benchmark results in your terminal output: |
| 11 | |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 12 | ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' |
| 13 | |
| 14 | See also bench-history. |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 15 | """ |
| 16 | |
Zachary Turner | ff890da | 2015-10-19 23:45:41 +0000 | [diff] [blame] | 17 | from __future__ import print_function |
| 18 | |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 19 | import os, sys |
| 20 | import re |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 21 | from optparse import OptionParser |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 22 | |
| 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. |
| 25 | benches = [ |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 26 | # 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 Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 28 | |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 29 | # Measure 'frame variable' response after stopping at a breakpoint. |
| 30 | './dotest.py -v +b %E %X -n -p TestFrameVariableResponse.py', |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 31 | |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 32 | # Measure stepping speed after stopping at a breakpoint. |
| 33 | './dotest.py -v +b %E %X -n -p TestSteppingSpeed.py', |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 34 | |
| 35 | # Measure expression cmd response with a simple custom executable program. |
| 36 | './dotest.py +b -n -p TestExpressionCmd.py', |
| 37 | |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 38 | # Attach to a spawned process then run disassembly benchmarks. |
| 39 | './dotest.py -v +b -n %E -p TestDoAttachThenDisassembly.py' |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 40 | ] |
| 41 | |
| 42 | def main(): |
| 43 | """Read the items from 'benches' and run the command line one by one.""" |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 44 | parser = OptionParser(usage="""\ |
| 45 | %prog [options] |
| 46 | Run 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 Turner | ff890da | 2015-10-19 23:45:41 +0000 | [diff] [blame] | 60 | print("Starting bench runner....") |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 61 | |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 62 | 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 Turner | ff890da | 2015-10-19 23:45:41 +0000 | [diff] [blame] | 67 | print("Running %s" % (command)) |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 68 | os.system(command) |
| 69 | |
Zachary Turner | ff890da | 2015-10-19 23:45:41 +0000 | [diff] [blame] | 70 | print("Bench runner done.") |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 71 | |
| 72 | if __name__ == '__main__': |
| 73 | main() |