Home | History | Annotate | Download | only in test
      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 
     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.
     15 """
     16 
     17 import os, sys
     18 import re
     19 from optparse import OptionParser
     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 = [
     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',
     26 
     27     # Measure 'frame variable' response after stopping at a breakpoint.
     28     './dotest.py -v +b %E %X -n -p TestFrameVariableResponse.py',
     29 
     30     # Measure stepping speed after stopping at a breakpoint.
     31     './dotest.py -v +b %E %X -n -p TestSteppingSpeed.py',
     32 
     33     # Measure expression cmd response with a simple custom executable program.
     34     './dotest.py +b -n -p TestExpressionCmd.py',
     35 
     36     # Attach to a spawned process then run disassembly benchmarks.
     37     './dotest.py -v +b -n %E -p TestDoAttachThenDisassembly.py'
     38 ]
     39 
     40 def main():
     41     """Read the items from 'benches' and run the command line one by one."""
     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                           
     58     print "Starting bench runner...."
     59 
     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 '')
     65         print "Running %s" % (command)
     66         os.system(command)
     67 
     68     print "Bench runner done."
     69 
     70 if __name__ == '__main__':
     71     main()
     72