summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-07-07 07:06:08 -0400
committerNed Batchelder <ned@nedbatchelder.com>2019-07-07 13:39:13 -0400
commit9c160feb307c85e8fbc4aae10ff7f33311c5f8d6 (patch)
tree303b472a2947f18ef99fe9696c32b1b397506a80
parent2c4c254a32e27c24b7714d541bd41eef97c375b5 (diff)
downloadpython-coveragepy-git-9c160feb307c85e8fbc4aae10ff7f33311c5f8d6.tar.gz
Rough-hewn use of ox_profile
-rw-r--r--coverage/cmdline.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py
index 354ae8c2..fdab7d93 100644
--- a/coverage/cmdline.py
+++ b/coverage/cmdline.py
@@ -799,3 +799,22 @@ def main(argv=None):
else:
status = None
return status
+
+# Profiling using ox_profile. Install it from GitHub:
+# pip install git+https://github.com/emin63/ox_profile.git
+#
+# $set_env.py: COVERAGE_PROFILE - Set to use ox_profile.
+_profile = os.environ.get("COVERAGE_PROFILE", "")
+if _profile: # pragma: debugging
+ from ox_profile.core.launchers import SimpleLauncher # pylint: disable=import-error
+ original_main = main
+
+ def main(argv=None): # pylint: disable=function-redefined
+ """A wrapper around main that profiles."""
+ try:
+ profiler = SimpleLauncher.launch()
+ return original_main(argv)
+ finally:
+ data, _ = profiler.query(re_filter='coverage', max_records=100)
+ print(profiler.show(query=data, limit=100, sep='', col=''))
+ profiler.cancel()