changeset 41470:d1a273074f62

perf: add a --[no-]clear-caches option to `perfnodemap` The option is useful to look at pure lookup performance on a warm data structure.
author Boris Feld <boris.feld@octobus.net>
date Mon, 28 Jan 2019 03:41:33 -0500
parents c9ff93889550
children 268325697a47
files contrib/perf.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf.py	Fri Jan 25 18:55:45 2019 -0500
+++ b/contrib/perf.py	Mon Jan 28 03:41:33 2019 -0500
@@ -1068,7 +1068,8 @@
     fm.end()
 
 @command(b'perfnodemap', [
-            (b'', b'rev', [], b'revision to be looked up (default tip)'),
+          (b'', b'rev', [], b'revision to be looked up (default tip)'),
+          (b'', b'clear-caches', True, b'clear revlog cache between calls'),
     ] + formatteropts)
 def perfnodemap(ui, repo, **opts):
     """benchmark the time necessary to look up revision from a cold nodemap
@@ -1093,6 +1094,7 @@
     mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg
 
     unfi = repo.unfiltered()
+    clearcaches = opts['clear_caches']
     # find the filecache func directly
     # This avoid polluting the benchmark with the filecache logic
     makecl = unfi.__class__.changelog.func
@@ -1109,13 +1111,18 @@
         clearchangelog(unfi)
         nodeget[0] = makecl(unfi).nodemap.get
 
-    def setup():
-        setnodeget()
     def d():
         get = nodeget[0]
         for n in nodes:
             get(n)
 
+    setup = None
+    if clearcaches:
+        def setup():
+            setnodeget()
+    else:
+        setnodeget()
+        d() # prewarm the data structure
     timer(d, setup=setup)
     fm.end()