2011-10-22 08:57:05 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
|
|
|
A simple bench runner which delegates to the ./dotest.py 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:
|
|
|
|
|
2011-10-27 06:58:02 +08:00
|
|
|
./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:'
|
|
|
|
|
|
|
|
See also bench-history.
|
2011-10-22 08:57:05 +08:00
|
|
|
"""
|
|
|
|
|
2015-10-20 07:45:41 +08:00
|
|
|
from __future__ import print_function
|
Python 3 - Turn on absolute imports, and fix existing imports.
Absolute imports were introduced in Python 2.5 as a feature
(e.g. from __future__ import absolute_import), and made default
in Python 3.
When absolute imports are enabled, the import system changes in
a couple of ways:
1) The `import foo` syntax will *only* search sys.path. If `foo`
isn't in sys.path, it won't be found. Period. Without absolute
imports, the import system will also search the same directory
that the importing file resides in, so that you can easily
import from the same folder.
2) From inside a package, you can use a dot syntax to refer to higher
levels of the current package. For example, if you are in the
package lldbsuite.test.utility, then ..foo refers to
lldbsuite.test.foo. You can use this notation with the
`from X import Y` syntax to write intra-package references. For
example, using the previous locationa s a starting point, writing
`from ..support import seven` would import lldbsuite.support.seven
Since this is now the default behavior in Python 3, this means that
importing from the same directory with `import foo` *no longer works*.
As a result, the only way to have portable code is to force absolute
imports for all versions of Python.
See PEP 0328 [https://www.python.org/dev/peps/pep-0328/] for more
information about absolute and relative imports.
Differential Revision: http://reviews.llvm.org/D14342
Reviewed By: Todd Fiala
llvm-svn: 252191
2015-11-06 03:22:28 +08:00
|
|
|
from __future__ import absolute_import
|
2015-10-20 07:45:41 +08:00
|
|
|
|
2011-10-22 08:57:05 +08:00
|
|
|
import os, sys
|
|
|
|
import re
|
2011-10-27 06:58:02 +08:00
|
|
|
from optparse import OptionParser
|
2011-10-22 08:57:05 +08:00
|
|
|
|
|
|
|
# dotest.py invocation with no '-e exe-path' uses lldb as the inferior program,
|
|
|
|
# unless there is a mentioning of custom executable program.
|
|
|
|
benches = [
|
2011-10-27 06:58:02 +08:00
|
|
|
# Measure startup delays creating a target, setting a breakpoint, and run to breakpoint stop.
|
|
|
|
'./dotest.py -v +b %E %X -n -p TestStartupDelays.py',
|
2011-10-22 08:57:05 +08:00
|
|
|
|
2011-10-27 06:58:02 +08:00
|
|
|
# Measure 'frame variable' response after stopping at a breakpoint.
|
|
|
|
'./dotest.py -v +b %E %X -n -p TestFrameVariableResponse.py',
|
2011-10-22 08:57:05 +08:00
|
|
|
|
2011-10-27 06:58:02 +08:00
|
|
|
# Measure stepping speed after stopping at a breakpoint.
|
|
|
|
'./dotest.py -v +b %E %X -n -p TestSteppingSpeed.py',
|
2011-10-22 08:57:05 +08:00
|
|
|
|
|
|
|
# Measure expression cmd response with a simple custom executable program.
|
|
|
|
'./dotest.py +b -n -p TestExpressionCmd.py',
|
|
|
|
|
2011-10-27 06:58:02 +08:00
|
|
|
# Attach to a spawned process then run disassembly benchmarks.
|
|
|
|
'./dotest.py -v +b -n %E -p TestDoAttachThenDisassembly.py'
|
2011-10-22 08:57:05 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
def main():
|
|
|
|
"""Read the items from 'benches' and run the command line one by one."""
|
2011-10-27 06:58:02 +08:00
|
|
|
parser = OptionParser(usage="""\
|
|
|
|
%prog [options]
|
|
|
|
Run the standard benchmarks defined in the list named 'benches'.\
|
|
|
|
""")
|
|
|
|
parser.add_option('-e', '--executable',
|
|
|
|
type='string', action='store',
|
|
|
|
dest='exe',
|
|
|
|
help='The target program launched by lldb.')
|
|
|
|
parser.add_option('-x', '--breakpoint-spec',
|
|
|
|
type='string', action='store',
|
|
|
|
dest='break_spec',
|
|
|
|
help='The lldb breakpoint spec for the target program.')
|
|
|
|
|
|
|
|
# Parses the options, if any.
|
|
|
|
opts, args = parser.parse_args()
|
|
|
|
|
2015-10-20 07:45:41 +08:00
|
|
|
print("Starting bench runner....")
|
2011-10-22 08:57:05 +08:00
|
|
|
|
2011-10-27 06:58:02 +08:00
|
|
|
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 '')
|
2015-10-20 07:45:41 +08:00
|
|
|
print("Running %s" % (command))
|
2011-10-22 08:57:05 +08:00
|
|
|
os.system(command)
|
|
|
|
|
2015-10-20 07:45:41 +08:00
|
|
|
print("Bench runner done.")
|
2011-10-22 08:57:05 +08:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|