Patchwork [5,of,5] perf: move revlog construction and length calculation out of benchmark

login
register
mail settings
Submitter Gregory Szorc
Date May 6, 2017, 6:22 p.m.
Message ID <975e9dc35eccecb00284.1494094921@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/20490/
State Accepted
Headers show

Comments

Gregory Szorc - May 6, 2017, 6:22 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1494094619 25200
#      Sat May 06 11:16:59 2017 -0700
# Node ID 975e9dc35eccecb002843848d91964bca327e33a
# Parent  cff951b580bade53bb5a520b690feb5ca73361d7
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.
Augie Fackler - May 8, 2017, 7:27 p.m.
On Sat, May 06, 2017 at 11:22:01AM -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1494094619 25200
> #      Sat May 06 11:16:59 2017 -0700
> # Node ID 975e9dc35eccecb002843848d91964bca327e33a
> # Parent  cff951b580bade53bb5a520b690feb5ca73361d7
> perf: move revlog construction and length calculation out of benchmark

queued, thanks

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -851,14 +851,14 @@  def perfrevlog(ui, repo, file_=None, sta
 
     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:
@@ -866,7 +866,7 @@  def perfrevlog(ui, repo, file_=None, sta
             dist = -1 * dist
 
         for x in xrange(beginrev, endrev, dist):
-            r.revision(x)
+            rl.revision(x)
 
     timer, fm = gettimer(ui, opts)
     timer(d)