perf: offer perf.stub to only run one loop
authortimeless <timeless@mozdev.org>
Fri, 04 Dec 2015 17:41:30 +0000
changeset 27304 a6fd79495770
parent 27303 57bd9c5431a5
child 27305 5831cfbf0e33
perf: offer perf.stub to only run one loop
contrib/perf.py
--- a/contrib/perf.py	Fri Dec 04 17:41:02 2015 +0000
+++ b/contrib/perf.py	Fri Dec 04 17:41:30 2015 +0000
@@ -29,8 +29,15 @@
     ui.fout = ui.ferr
     # get a formatter
     fm = ui.formatter('perf', opts)
+    # stub function, runs code only once instead of in a loop
+    # experimental config: perf.stub
+    if ui.configbool("perf", "stub"):
+        return functools.partial(stub_timer, fm), fm
     return functools.partial(_timer, fm), fm
 
+def stub_timer(fm, func, title=None):
+    func()
+
 def _timer(fm, func, title=None):
     results = []
     begin = time.time()