Created
September 27, 2015 23:22
-
-
Save mateor/a38e1c7481d0ab0b1d7f to your computer and use it in GitHub Desktop.
python profiling in pants snippet. Install guppy into the virtual env (env/bin/pip install guppy).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _run(exiter): | |
# We want to present warnings to the user, set this up early to ensure all warnings are seen. | |
# The "default" action displays a warning for a particular file and line number exactly once. | |
# See https://docs.python.org/2/library/warnings.html#the-warnings-filter for the complete action | |
# list. | |
warnings.simplefilter('default') | |
# Bootstrap options and logging. | |
options, build_config = OptionsInitializer().setup() | |
# Apply exiter options. | |
exiter.apply_options(options) | |
# Launch RunTracker as early as possible (just after Subsystem options are initialized). | |
run_tracker, reporting = ReportingInitializer().setup() | |
# Determine the build root dir. | |
root_dir = get_buildroot() | |
# Setup and run GoalRunner. | |
try: | |
from guppy import hpy | |
h = hpy() | |
before = h.heap() | |
goal_runner = GoalRunner.Factory(root_dir, options, build_config, run_tracker, reporting).setup() | |
result = goal_runner.run() | |
except KeyboardInterrupt: | |
after = h.heap() | |
pants_heap = after - before | |
print("!!!!!!! Starting a trace !!!!!!!!!!!!!!") | |
import pdb; pdb.set_trace() | |
print("!!!!!!! Ending a trace !!!!!!!!!!!!!!") | |
exiter.do_exit(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment