changeset 25107:149cc7663ac8

run-tests: add a --profile-runner option While in the throes of a recent run-tests adventure, I found it useful to have profiler output for the testrunner itself. Adding it was simple enough and seems worth keeping around.
author Augie Fackler <augie@google.com>
date Wed, 13 May 2015 11:22:06 -0700
parents 6f15114bdcc3
children 09ec4220a839
files tests/run-tests.py
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Fri May 15 10:24:59 2015 +0200
+++ b/tests/run-tests.py	Wed May 13 11:22:06 2015 -0700
@@ -240,6 +240,8 @@
                       help='set the given config opt in the test hgrc')
     parser.add_option('--random', action="store_true",
                       help='run tests in random order')
+    parser.add_option('--profile-runner', action='store_true',
+                      help='run statprof on run-tests')
 
     for option, (envvar, default) in defaults.items():
         defaults[option] = type(default)(os.environ.get(envvar, default))
@@ -1660,7 +1662,15 @@
 
             self._checktools()
             tests = self.findtests(args)
-            return self._run(tests)
+            if options.profile_runner:
+                import statprof
+                statprof.start()
+            result = self._run(tests)
+            if options.profile_runner:
+                statprof.stop()
+                statprof.display()
+            return result
+
         finally:
             os.umask(oldmask)