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.
--- 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)