changeset 41439:7eb7637e34bf

perf: support looking up multiple revisions The nodemap code has optimisations around the number of lookup we actually made. As a result, being able to specify multiple revisions to look up is important when measuring performances. One can now specify full revspecs with the --rev arguments.
author Boris Feld <boris.feld@octobus.net>
date Mon, 28 Jan 2019 03:20:31 -0500
parents e9891c734bf8
children 1bc01490178a
files contrib/perf.py
diffstat 1 files changed, 22 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf.py	Fri Jan 25 18:43:48 2019 -0500
+++ b/contrib/perf.py	Mon Jan 28 03:20:31 2019 -0500
@@ -1014,7 +1014,7 @@
     fm.end()
 
 @command(b'perfindex', [
-            (b'', b'rev', b'', b'revision to be looked up (default tip)'),
+            (b'', b'rev', [], b'revision to be looked up (default tip)'),
             (b'', b'no-lookup', None, b'do not revision lookup post creation'),
          ] + formatteropts)
 def perfindex(ui, repo, **opts):
@@ -1023,7 +1023,18 @@
     The default is to look `tip` up. Depending on the index implementation,
     the revision looked up can matters. For example, an implementation
     scanning the index will have a faster lookup time for `--rev tip` than for
-    `--rev 0`.
+    `--rev 0`. The number of looked up revisions and their order can also
+    matters.
+
+    Example of useful set to test:
+    * tip
+    * 0
+    * -10:
+    * :10
+    * -10: + :10
+    * :10: + -10:
+    * -10000:
+    * -10000: + 0
 
     It is not currently possible to check for lookup of a missing node."""
     import mercurial.revlog
@@ -1031,12 +1042,15 @@
     timer, fm = gettimer(ui, opts)
     mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg
     if opts[b'no_lookup']:
-        n = None
-    elif opts[b'rev'] is None:
-        n = repo[b"tip"].node()
+        if opts['rev']:
+            raise error.Abort('--no-lookup and --rev are mutually exclusive')
+        nodes = []
+    elif not opts[b'rev']:
+        nodes = [repo[b"tip"].node()]
     else:
-        rev = scmutil.revsingle(repo, opts[b'rev'])
-        n = repo[rev].node()
+        revs = scmutil.revrange(repo, opts[b'rev'])
+        cl = repo.changelog
+        nodes = [cl.node(r) for r in revs]
 
     unfi = repo.unfiltered()
     # find the filecache func directly
@@ -1047,7 +1061,7 @@
         clearchangelog(unfi)
     def d():
         cl = makecl(unfi)
-        if n is not None:
+        for n in nodes:
             cl.rev(n)
     timer(d, setup=setup)
     fm.end()