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

Simon Farnsworth simonfar at fb.com
Fri Feb 10 16:06:17 EST 2017


# HG changeset patch
# User Simon Farnsworth <simonfar at 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)

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()
 
+ at 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


More information about the Mercurial-devel mailing list