Johnny Chen | eef9057 | 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 | ebbec4c | 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 | eef9057 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 15 | """ |
| 16 | |
| 17 | import os, sys |
| 18 | import re |
Johnny Chen | ebbec4c | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 19 | from optparse import OptionParser |
Johnny Chen | eef9057 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 20 | |
| 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. |
| 23 | benches = [ |
Johnny Chen | ebbec4c | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 24 | # 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 Chen | eef9057 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 26 | |
Johnny Chen | ebbec4c | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 27 | # Measure 'frame variable' response after stopping at a breakpoint. |
| 28 | './dotest.py -v +b %E %X -n -p TestFrameVariableResponse.py', |
Johnny Chen | eef9057 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 29 | |
Johnny Chen | ebbec4c | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 30 | # Measure stepping speed after stopping at a breakpoint. |
| 31 | './dotest.py -v +b %E %X -n -p TestSteppingSpeed.py', |
Johnny Chen | eef9057 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 32 | |
| 33 | # Measure expression cmd response with a simple custom executable program. |
| 34 | './dotest.py +b -n -p TestExpressionCmd.py', |
| 35 | |
Johnny Chen | ebbec4c | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 36 | # Attach to a spawned process then run disassembly benchmarks. |
| 37 | './dotest.py -v +b -n %E -p TestDoAttachThenDisassembly.py' |
Johnny Chen | eef9057 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 38 | ] |
| 39 | |
| 40 | def main(): |
| 41 | """Read the items from 'benches' and run the command line one by one.""" |
Johnny Chen | ebbec4c | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 42 | parser = OptionParser(usage="""\ |
| 43 | %prog [options] |
| 44 | Run 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 Chen | eef9057 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 58 | print "Starting bench runner...." |
| 59 | |
Johnny Chen | ebbec4c | 2011-10-26 22:58:02 +0000 | [diff] [blame] | 60 | 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 Chen | eef9057 | 2011-10-22 00:57:05 +0000 | [diff] [blame] | 65 | print "Running %s" % (command) |
| 66 | os.system(command) |
| 67 | |
| 68 | print "Bench runner done." |
| 69 | |
| 70 | if __name__ == '__main__': |
| 71 | main() |