[PATCH 3 of 6 frozen-repos] revsetbenchmarks: support benchmarking changectx loading

Gregory Szorc gregory.szorc at gmail.com
Sat Nov 21 19:14:00 CST 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1448149384 28800
#      Sat Nov 21 15:43:04 2015 -0800
# Node ID f559e16232491e44fc4dac6c12872cb2e9164d27
# Parent  2dd44d0377a2a9f7266e156dc262737e0139c7af
revsetbenchmarks: support benchmarking changectx loading

Many revset consumers construct changectx instances for each returned
result. Add support for benchmarking this to our revset benchmark
script.

In the future, we might want to have some kind of special syntax in
the parsed revset files to engage this mode automatically. This would
enable us to load changectxs for revsets that do that in the code and
would more accurately benchmark what's actually happening. For now,
running all revsets with or without changectxs is sufficient.

diff --git a/contrib/revsetbenchmarks.py b/contrib/revsetbenchmarks.py
--- a/contrib/revsetbenchmarks.py
+++ b/contrib/revsetbenchmarks.py
@@ -48,20 +48,23 @@ def hg(cmd, repo=None):
     fullcmd = ['./hg']
     if repo is not None:
         fullcmd += ['-R', repo]
     fullcmd += ['--config',
                 'extensions.perf=' + os.path.join(contribdir, 'perf.py')]
     fullcmd += cmd
     return check_output(fullcmd, stderr=STDOUT)
 
-def perf(revset, target=None):
+def perf(revset, target=None, contexts=False):
     """run benchmark for this very revset"""
     try:
-        output = hg(['perfrevset', revset], repo=target)
+        args = ['perfrevset', revset]
+        if contexts:
+            args.append('--contexts')
+        output = hg(args, repo=target)
         return parseoutput(output)
     except CalledProcessError as exc:
         print >> sys.stderr, 'abort: cannot run revset benchmark: %s' % exc.cmd
         if exc.output is None:
             print >> sys.stderr, '(no output)'
         else:
             print >> sys.stderr, exc.output
         return None
@@ -233,16 +236,19 @@ parser.add_option("-R", "--repo",
 parser.add_option("-v", "--verbose",
                   action='store_true',
                   help="display all timing data (not just best total time)")
 
 parser.add_option("", "--variants",
                   default=','.join(DEFAULTVARIANTS),
                   help="comma separated list of variant to test "
                        "(eg: plain,min,sorted) (plain = no modification)")
+parser.add_option('-x', '--contexts',
+                  action='store_true',
+                  help='obtain changectx from results instead of integer revs')
 
 (options, args) = parser.parse_args()
 
 if not args:
     parser.print_help()
     sys.exit(255)
 
 # the directory where both this script and the perf.py extension live.
@@ -278,17 +284,17 @@ for r in revs:
     update(r)
     res = []
     results.append(res)
     printheader(variants, len(revsets), verbose=options.verbose)
     for idx, rset in enumerate(revsets):
         varres = {}
         for var in variants:
             varrset = applyvariants(rset, var)
-            data = perf(varrset, target=options.repo)
+            data = perf(varrset, target=options.repo, contexts=options.contexts)
             varres[var] = data
         res.append(varres)
         printresult(variants, idx, varres, len(revsets),
                     verbose=options.verbose)
         sys.stdout.flush()
     print "----------------------------"
 
 


More information about the Mercurial-devel mailing list