comparison contrib/revsetbenchmarks.py @ 27073:b9fc042168a4

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 21 Nov 2015 15:43:04 -0800
parents 1aee2ab0f902
children c4bec3c45ec9
comparison
equal deleted inserted replaced
27072:e18a9ceade3b 27073:b9fc042168a4
51 fullcmd += ['--config', 51 fullcmd += ['--config',
52 'extensions.perf=' + os.path.join(contribdir, 'perf.py')] 52 'extensions.perf=' + os.path.join(contribdir, 'perf.py')]
53 fullcmd += cmd 53 fullcmd += cmd
54 return check_output(fullcmd, stderr=STDOUT) 54 return check_output(fullcmd, stderr=STDOUT)
55 55
56 def perf(revset, target=None): 56 def perf(revset, target=None, contexts=False):
57 """run benchmark for this very revset""" 57 """run benchmark for this very revset"""
58 try: 58 try:
59 output = hg(['perfrevset', revset], repo=target) 59 args = ['perfrevset', revset]
60 if contexts:
61 args.append('--contexts')
62 output = hg(args, repo=target)
60 return parseoutput(output) 63 return parseoutput(output)
61 except CalledProcessError as exc: 64 except CalledProcessError as exc:
62 print >> sys.stderr, 'abort: cannot run revset benchmark: %s' % exc.cmd 65 print >> sys.stderr, 'abort: cannot run revset benchmark: %s' % exc.cmd
63 if exc.output is None: 66 if exc.output is None:
64 print >> sys.stderr, '(no output)' 67 print >> sys.stderr, '(no output)'
236 239
237 parser.add_option("", "--variants", 240 parser.add_option("", "--variants",
238 default=','.join(DEFAULTVARIANTS), 241 default=','.join(DEFAULTVARIANTS),
239 help="comma separated list of variant to test " 242 help="comma separated list of variant to test "
240 "(eg: plain,min,sorted) (plain = no modification)") 243 "(eg: plain,min,sorted) (plain = no modification)")
244 parser.add_option('', '--contexts',
245 action='store_true',
246 help='obtain changectx from results instead of integer revs')
241 247
242 (options, args) = parser.parse_args() 248 (options, args) = parser.parse_args()
243 249
244 if not args: 250 if not args:
245 parser.print_help() 251 parser.print_help()
281 printheader(variants, len(revsets), verbose=options.verbose) 287 printheader(variants, len(revsets), verbose=options.verbose)
282 for idx, rset in enumerate(revsets): 288 for idx, rset in enumerate(revsets):
283 varres = {} 289 varres = {}
284 for var in variants: 290 for var in variants:
285 varrset = applyvariants(rset, var) 291 varrset = applyvariants(rset, var)
286 data = perf(varrset, target=options.repo) 292 data = perf(varrset, target=options.repo, contexts=options.contexts)
287 varres[var] = data 293 varres[var] = data
288 res.append(varres) 294 res.append(varres)
289 printresult(variants, idx, varres, len(revsets), 295 printresult(variants, idx, varres, len(revsets),
290 verbose=options.verbose) 296 verbose=options.verbose)
291 sys.stdout.flush() 297 sys.stdout.flush()