Submitter | Simon Farnsworth |
---|---|
Date | Feb. 10, 2017, 9:06 p.m. |
Message ID | <838c119320b457e9dfcc.1486760777@devvm022.lla2.facebook.com> |
Download | mbox | patch |
Permalink | /patch/18409/ |
State | Changes Requested |
Headers | show |
Comments
On Fri, Feb 10, 2017 at 1:06 PM, Simon Farnsworth <simonfar@fb.com> wrote: > + def write(): > + ui.write(('Testing write performance\n')) > You'll want to do this in a loop 10,000 times or something instead of just once, so that the numbers you get actually give you some idea of what's going on. When you just measure one call, the cost of the call is probably lower than the resolution of time.time().
Patch
diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -1257,6 +1257,16 @@ timer(fn, title=title) fm.end() +@command('perfwrite', formatteropts) +def perfwrite(ui, repo, **opts): + """microbenchmark ui.write + """ + timer, fm = gettimer(ui, opts) + def write(): + ui.write(('Testing write performance\n')) + timer(write) + fm.end() + def uisetup(ui): if (util.safehasattr(cmdutil, 'openrevlog') and not util.safehasattr(commands, 'debugrevlogopts')): diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t --- a/tests/test-contrib-perf.t +++ b/tests/test-contrib-perf.t @@ -109,6 +109,7 @@ perfvolatilesets benchmark the computation of various volatile set perfwalk (no help text available) + perfwrite microbenchmark ui.write (use 'hg help -v perfstatusext' to show built-in aliases and global options) $ hg perfaddremove