contrib/perf.py
changeset 27304 a6fd79495770
parent 27303 57bd9c5431a5
child 27305 5831cfbf0e33
--- 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()