Patchwork [5,of,9] revsetbenchmark: convert performance call to proper subprocess call

login
register
mail settings
Submitter Pierre-Yves David
Date March 27, 2014, 2:49 a.m.
Message ID <08e5abec5ea0d3e09088.1395888546@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4084/
State Accepted
Commit 4130ec938c846629777e87ecbff0ed17b863710b
Headers show

Comments

Pierre-Yves David - March 27, 2014, 2:49 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1395883578 25200
#      Wed Mar 26 18:26:18 2014 -0700
# Node ID 08e5abec5ea0d3e090880a62e577255972cc0cfd
# Parent  a9b35a2e2cb09bdb1e504ab7aab0ae4718723d4a
revsetbenchmark: convert performance call to proper subprocess call

Patch

diff --git a/contrib/revsetbenchmarks.py b/contrib/revsetbenchmarks.py
--- a/contrib/revsetbenchmarks.py
+++ b/contrib/revsetbenchmarks.py
@@ -23,11 +23,19 @@  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)
 
-PERF="./hg --config extensions.perf=contrib/perf.py perfrevset"
+def perf(revset):
+    """run benchmark for this very revset"""
+    try:
+        check_call(['./hg', '--config', 'extensions.perf=contrib/perf.py',
+                    'perfrevset', revset])
+    except CalledProcessError, exc:
+        print >> sys.stderr, 'abort: cannot run revset benchmark'
+        sys.exit(exc.returncode)
+
 
 target_rev = sys.argv[1]
 
 revsetsfile = sys.stdin
 if len(sys.argv) > 2:
@@ -59,8 +67,8 @@  for r in revs:
     print "----------------------------"
     update(r)
     for idx, rset in enumerate(revsets):
         sys.stdout.write("%i) " % idx)
         sys.stdout.flush()
-        check_call(PERF + ' "%s"' % rset, shell=True)
+        perf(rset)
     print "----------------------------"