mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-06 12:56:08 +00:00

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
75 lines
2.6 KiB
Python
75 lines
2.6 KiB
Python
#!/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:
|
|
|
|
./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.
|
|
"""
|
|
|
|
from __future__ import print_function
|
|
from __future__ import absolute_import
|
|
|
|
import os, sys
|
|
import re
|
|
from optparse import OptionParser
|
|
|
|
# dotest.py 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.
|
|
'./dotest.py -v +b %E %X -n -p TestStartupDelays.py',
|
|
|
|
# Measure 'frame variable' response after stopping at a breakpoint.
|
|
'./dotest.py -v +b %E %X -n -p TestFrameVariableResponse.py',
|
|
|
|
# Measure stepping speed after stopping at a breakpoint.
|
|
'./dotest.py -v +b %E %X -n -p TestSteppingSpeed.py',
|
|
|
|
# Measure expression cmd response with a simple custom executable program.
|
|
'./dotest.py +b -n -p TestExpressionCmd.py',
|
|
|
|
# Attach to a spawned process then run disassembly benchmarks.
|
|
'./dotest.py -v +b -n %E -p TestDoAttachThenDisassembly.py'
|
|
]
|
|
|
|
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',
|
|
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()
|
|
|
|
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))
|
|
os.system(command)
|
|
|
|
print("Bench runner done.")
|
|
|
|
if __name__ == '__main__':
|
|
main()
|