[plain text]

#!/usr/bin/env python

A simple bench runner which delegates to the ./ test driver to run the
benchmarks defined in the list named 'benches'.

You need to hand edit 'benches' to modify/change the command lines passed to the
test driver.

Use the following to get only the benchmark results in your terminal output:

    ./ -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:'

See also bench-history.

import os, sys
import re
from optparse import OptionParser

# invocation with no '-e exe-path' uses lldb as the inferior program,
# unless there is a mentioning of custom executable program.
benches = [
    # Measure startup delays creating a target, setting a breakpoint, and run to breakpoint stop.
    './ -v +b %E %X -n -p',

    # Measure 'frame variable' response after stopping at a breakpoint.
    './ -v +b %E %X -n -p',

    # Measure stepping speed after stopping at a breakpoint.
    './ -v +b %E %X -n -p',

    # Measure expression cmd response with a simple custom executable program.
    './ +b -n -p',

    # Attach to a spawned process then run disassembly benchmarks.
    './ -v +b -n %E -p'

def main():
    """Read the items from 'benches' and run the command line one by one."""
    parser = OptionParser(usage="""\
%prog [options]
Run the standard benchmarks defined in the list named 'benches'.\
    parser.add_option('-e', '--executable',
                      type='string', action='store',
                      help='The target program launched by lldb.')
    parser.add_option('-x', '--breakpoint-spec',
                      type='string', action='store',
                      help='The lldb breakpoint spec for the target program.')

    # Parses the options, if any.
    opts, args = parser.parse_args()
    print "Starting bench runner...."

    for item in benches:
        command = item.replace('%E',
                               '-e "%s"' % opts.exe if opts.exe else '')
        command = command.replace('%X',
                               '-x "%s"' % opts.break_spec if opts.break_spec else '')
        print "Running %s" % (command)

    print "Bench runner done."

if __name__ == '__main__':