Mercurial > hg
changeset 27304:a6fd79495770
perf: offer perf.stub to only run one loop
author | timeless <timeless@mozdev.org> |
---|---|
date | Fri, 04 Dec 2015 17:41:30 +0000 |
parents | 57bd9c5431a5 |
children | 5831cfbf0e33 |
files | contrib/perf.py |
diffstat | 1 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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()