contrib/revsetbenchmarks.py
changeset 27073 b9fc042168a4
parent 26781 1aee2ab0f902
child 28073 c4bec3c45ec9
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()