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 |
Zachary Turner | c1b7cd7 | 2015-11-05 19:22:28 +0000 | [diff] [blame] | 18 | from __future__ import absolute_import |
Zachary Turner | ff890da | 2015-10-19 23:45:41 +0000 | [diff] [blame] | 19 | |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 20 | import os, sys |
| 21 | import re |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 22 | from optparse import OptionParser |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 23 | |
| 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. |
| 26 | benches = [ |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 27 | # 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 Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 29 | |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 30 | # Measure 'frame variable' response after stopping at a breakpoint. |
| 31 | './dotest.py -v +b %E %X -n -p TestFrameVariableResponse.py', |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 32 | |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 33 | # Measure stepping speed after stopping at a breakpoint. |
| 34 | './dotest.py -v +b %E %X -n -p TestSteppingSpeed.py', |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 35 | |
| 36 | # Measure expression cmd response with a simple custom executable program. |
| 37 | './dotest.py +b -n -p TestExpressionCmd.py', |
| 38 | |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 39 | # Attach to a spawned process then run disassembly benchmarks. |
| 40 | './dotest.py -v +b -n %E -p TestDoAttachThenDisassembly.py' |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 41 | ] |
| 42 | |
| 43 | def main(): |
| 44 | """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] | 45 | parser = OptionParser(usage="""\ |
| 46 | %prog [options] |
| 47 | Run 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 Turner | ff890da | 2015-10-19 23:45:41 +0000 | [diff] [blame] | 61 | print("Starting bench runner....") |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 62 | |
Johnny Chen | 66d362e | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 63 | 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 Turner | ff890da | 2015-10-19 23:45:41 +0000 | [diff] [blame] | 68 | print("Running %s" % (command)) |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 69 | os.system(command) |
| 70 | |
Zachary Turner | ff890da | 2015-10-19 23:45:41 +0000 | [diff] [blame] | 71 | print("Bench runner done.") |
Johnny Chen | b8da426 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 72 | |
| 73 | if __name__ == '__main__': |
| 74 | main() |