]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/bench.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / bench.py
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 from __future__ import print_function
18 from __future__ import absolute_import
19
20 import os, sys
21 import re
22 from optparse import OptionParser
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 = [
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',
29
30     # Measure 'frame variable' response after stopping at a breakpoint.
31     './dotest.py -v +b %E %X -n -p TestFrameVariableResponse.py',
32
33     # Measure stepping speed after stopping at a breakpoint.
34     './dotest.py -v +b %E %X -n -p TestSteppingSpeed.py',
35
36     # Measure expression cmd response with a simple custom executable program.
37     './dotest.py +b -n -p TestExpressionCmd.py',
38
39     # Attach to a spawned process then run disassembly benchmarks.
40     './dotest.py -v +b -n %E -p TestDoAttachThenDisassembly.py'
41 ]
42
43 def main():
44     """Read the items from 'benches' and run the command line one by one."""
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                           
61     print("Starting bench runner....")
62
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 '')
68         print("Running %s" % (command))
69         os.system(command)
70
71     print("Bench runner done.")
72
73 if __name__ == '__main__':
74     main()