Patchwork [3,of,3,V2] revsetbenchmark: support for running on other repo

login
register
mail settings
Submitter Pierre-Yves David
Date May 13, 2014, 8:19 a.m.
Message ID <c0450e789ff9879c4f2f.1399969157@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4736/
State Superseded
Headers show

Comments

Pierre-Yves David - May 13, 2014, 8:19 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1398805952 25200
#      Tue Apr 29 14:12:32 2014 -0700
# Node ID c0450e789ff9879c4f2fa3305b4db413f71b8804
# Parent  ecfe676f25f7c02f7eae88496de1adebb258f822
revsetbenchmark: support for running on other repo

We add a -R/--repo option to run the benchmarks on another repository. This is
very useful as some repository are bigger/more interesting  than the mercurial one.

Patch

diff --git a/contrib/revsetbenchmarks.py b/contrib/revsetbenchmarks.py
--- a/contrib/revsetbenchmarks.py
+++ b/contrib/revsetbenchmarks.py
@@ -36,20 +36,23 @@  def update(rev):
         check_call(['hg', 'update', '--quiet', '--check', str(rev)])
     except CalledProcessError, exc:
         print >> sys.stderr, 'update to revision %s failed, aborting' % rev
         sys.exit(exc.returncode)
 
-def perf(revset):
+def perf(revset, target=None):
     """run benchmark for this very revset"""
     try:
-        output = check_output(['./hg',
-                               '--config',
-                               'extensions.perf='
-                               + os.path.join(contribdir, 'perf.py'),
-                               'perfrevset',
-                               revset],
-                               stderr=STDOUT)
+        cmd = ['./hg',
+               '--config',
+               'extensions.perf='
+               + os.path.join(contribdir, 'perf.py'),
+               'perfrevset',
+               revset]
+        if target is not None:
+            cmd.append('-R')
+            cmd.append(target)
+        output = check_output(cmd, stderr=STDOUT)
         output = output.lstrip('!') # remove useless ! in this context
         return output.strip()
     except CalledProcessError, exc:
         print >> sys.stderr, 'abort: cannot run revset benchmark'
         sys.exit(exc.returncode)
@@ -72,10 +75,12 @@  def getrevs(spec):
 
 
 parser = OptionParser(usage="usage: %prog [options] <revs>")
 parser.add_option("-f", "--file",
                   help="read revset from FILE", metavar="FILE")
+parser.add_option("-R", "--repo",
+                  help="run benchmark on REPO", metavar="REPO")
 
 (options, args) = parser.parse_args()
 
 if len(sys.argv) < 2:
     parser.print_help()
@@ -110,11 +115,11 @@  for r in revs:
     print "----------------------------"
     update(r)
     res = []
     results.append(res)
     for idx, rset in enumerate(revsets):
-        data = perf(rset)
+        data = perf(rset, target=options.repo)
         res.append(data)
         print "%i)" % idx, data
         sys.stdout.flush()
     print "----------------------------"