Patchwork [3,of,8,v3] contrib: add a write microbenchmark to perf.py

login
register
mail settings
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

Simon Farnsworth - Feb. 10, 2017, 9:06 p.m.
# HG changeset patch
# User Simon Farnsworth <simonfar@fb.com>
# Date 1486760403 28800
#      Fri Feb 10 13:00:03 2017 -0800
# Node ID 838c119320b457e9dfcc45d3d8a50a48d5ea5243
# Parent  25b4512a095b2f3788b255274a15d68dbc10f7b4
contrib: add a write microbenchmark to perf.py

I'm adding some performance logging to ui.write - this benchmark lets us
confirm that the cost of that logging is acceptably low.

At this point, the microbenchmark on Linux over SSH shows:

! wall 0.000003 comb 0.000000 user 0.000000 sys 0.000000 (best of 82813)

while on the Mac locally, it shows:

! wall 0.000000 comb 0.000000 user 0.000000 sys 0.000000 (best of 318339)
Bryan O'Sullivan - Feb. 12, 2017, 4 a.m.
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