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.
--- a/contrib/revsetbenchmarks.py Sat Nov 21 15:39:18 2015 -0800
+++ b/contrib/revsetbenchmarks.py Sat Nov 21 15:43:04 2015 -0800
@@ -53,10 +53,13 @@
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
@@ -238,6 +241,9 @@
default=','.join(DEFAULTVARIANTS),
help="comma separated list of variant to test "
"(eg: plain,min,sorted) (plain = no modification)")
+parser.add_option('', '--contexts',
+ action='store_true',
+ help='obtain changectx from results instead of integer revs')
(options, args) = parser.parse_args()
@@ -283,7 +289,7 @@
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),