Patchwork [2,of,2,V3] revsetbenchmark: support for running on other repo

login
register
mail settings
Submitter Pierre-Yves David
Date May 14, 2014, 10:07 p.m.
Message ID <3f2947513de5688b8c6c.1400105257@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4740/
State Accepted
Headers show

Comments

Pierre-Yves David - May 14, 2014, 10:07 p.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 3f2947513de5688b8c6c6bb64b5d2a5214a78754
# Parent  2ec3ba5c35c852f8e9fe5ab28703088175de77a0
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.
Augie Fackler - May 26, 2014, 4:38 p.m.
On Wed, May 14, 2014 at 03:07:37PM -0700, pierre-yves.david@ens-lyon.org wrote:
> # 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 3f2947513de5688b8c6c6bb64b5d2a5214a78754
> # Parent  2ec3ba5c35c852f8e9fe5ab28703088175de77a0
> revsetbenchmark: support for running on other repo

These look good now, queued, thanks.

>
> 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.
>
> 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()
> @@ -111,11 +116,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 "----------------------------"
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

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()
@@ -111,11 +116,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 "----------------------------"