[PATCH 6 of 6 v2] extdiff: measure blocked time

Simon Farnsworth simonfar at fb.com
Thu Feb 2 14:19:00 EST 2017


# HG changeset patch
# User Simon Farnsworth <simonfar at fb.com>
# Date 1486063056 28800
#      Thu Feb 02 11:17:36 2017 -0800
# Node ID c85a13e4bbc3a26b6bf6f502c207f5491eb0889f
# Parent  581cb462ae6eb9ae95fdd64ec55df2b58ab6233a
extdiff: measure blocked time

Log the time spent in the external diff tool only - this is the bit that's outside our control

diff --git a/hgext/extdiff.py b/hgext/extdiff.py
--- a/hgext/extdiff.py
+++ b/hgext/extdiff.py
@@ -273,7 +273,18 @@
         cmdline = re.sub(regex, quote, cmdline)
 
         ui.debug('running %r in %s\n' % (cmdline, tmproot))
-        ui.system(cmdline, cwd=tmproot)
+        if ui.logblockedtime:
+            system = util.elapsedtimewrapper(ui.system)
+        else:
+            system = ui.system
+        try:
+            system(cmdline, cwd=tmproot)
+        finally:
+            if ui.logblockedtime:
+                ui.log('uiblocked',
+                       'extdiff blocked for %0.1f ms', system.elapsedms,
+                        extdiff_blocked=system.elapsedms)
+
 
         for copy_fn, working_fn, mtime in fns_and_mtime:
             if os.lstat(copy_fn).st_mtime != mtime:
diff --git a/tests/test-extdiff.t b/tests/test-extdiff.t
--- a/tests/test-extdiff.t
+++ b/tests/test-extdiff.t
@@ -72,6 +72,26 @@
   [1]
 #endif
 
+Should be able to measure blocked time:
+
+#if windows
+$ hg falabala -r 0:1 --config ui.logblockedtime=True --config extensions.logtoprocess= --config logtoprocess.uiblocked='echo uiblocked extdiff time $OPT_EXTDIFF_BLOCKED'| head -n50 | sort
+  diffing "*\\extdiff.*\\a.8a5febb7f867\\a" "a.34eed99112ab\\a" (glob)
+  uiblocked extdiff time
+  uiblocked extdiff time
+  uiblocked extdiff time
+  uiblocked extdiff time
+  uiblocked extdiff time .* (glob)
+#else
+  $ hg falabala -r 0:1 --config ui.logblockedtime=True --config extensions.logtoprocess= --config logtoprocess.uiblocked='echo uiblocked extdiff time $OPT_EXTDIFF_BLOCKED'| head -n50 | sort
+  diffing */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob)
+  uiblocked extdiff time
+  uiblocked extdiff time
+  uiblocked extdiff time
+  uiblocked extdiff time
+  uiblocked extdiff time .* (glob)
+#endif
+
 Specifying an empty revision should abort.
 
   $ hg extdiff -p diff --patch --rev 'ancestor()' --rev 1


More information about the Mercurial-devel mailing list