Patchwork [2,of,4] perf: add a --rev attribute to perfindex

login
register
mail settings
Submitter Boris Feld
Date Dec. 2, 2018, 4:17 p.m.
Message ID <0f29dba58034752d00c2.1543767461@pc62.home>
Download mbox | patch
Permalink /patch/36905/
State Accepted
Headers show

Comments

Boris Feld - Dec. 2, 2018, 4:17 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1543676247 -3600
#      Sat Dec 01 15:57:27 2018 +0100
# Node ID 0f29dba58034752d00c2c0000cbe41cc787b6dec
# Parent  63dc9727cc56dcf4995f45fdabb3c56ef84e4389
# EXP-Topic mmap
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 0f29dba58034
perf: add a --rev attribute to perfindex

This allow for benchmarking the time necessary to look for other version than
the tip.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -992,13 +992,19 @@  def perfignore(ui, repo, **opts):
     timer(runone, setup=setupone, title=b"load")
     fm.end()
 
-@command(b'perfindex', formatteropts)
+@command(b'perfindex', [
+            (b'', b'rev', '', b'revision to be looked up (default tip)'),
+         ] + formatteropts)
 def perfindex(ui, repo, **opts):
     import mercurial.revlog
     opts = _byteskwargs(opts)
     timer, fm = gettimer(ui, opts)
     mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg
-    n = repo[b"tip"].node()
+    if opts['rev'] is None:
+        n = repo[b"tip"].node()
+    else:
+        rev = scmutil.revsingle(repo, opts['rev'])
+        n = repo[rev].node()
 
     unfi = repo.unfiltered()
     # find the filecache func directly