perf: move revlog construction and length calculation out of benchmark
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 06 May 2017 11:16:59 -0700
changeset 32272 4c6b2076d292
parent 32271 954f63391d71
child 32273 feb910d2f59b
perf: move revlog construction and length calculation out of benchmark We don't need to measure the time it takes to open the revlog or calculate its length. This is more consistent with what other perf* functions do. While I was here, I also renamed the revlog variable from "r" to "rl" - again in the name of consistency.
contrib/perf.py
--- a/contrib/perf.py	Sat May 06 11:15:56 2017 -0700
+++ b/contrib/perf.py	Sat May 06 11:16:59 2017 -0700
@@ -850,14 +850,14 @@
 
     The start revision can be defined via ``-s/--startrev``.
     """
-    _len = getlen(ui)
+    rl = cmdutil.openrevlog(repo, 'perfrevlog', file_, opts)
+    rllen = getlen(ui)(rl)
 
     def d():
-        r = cmdutil.openrevlog(repo, 'perfrevlog', file_, opts)
-        r.clearcaches()
+        rl.clearcaches()
 
         beginrev = startrev
-        endrev = _len(r)
+        endrev = rllen
         dist = opts['dist']
 
         if reverse:
@@ -865,7 +865,7 @@
             dist = -1 * dist
 
         for x in xrange(beginrev, endrev, dist):
-            r.revision(x)
+            rl.revision(x)
 
     timer, fm = gettimer(ui, opts)
     timer(d)