contrib/perf.py
changeset 30336 7ddc8f8d7712
parent 30335 7d91a085ebe6
child 30337 6ecad4b73569
equal deleted inserted replaced
30335:7d91a085ebe6 30336:7ddc8f8d7712
   745         for p in s.fncache.entries:
   745         for p in s.fncache.entries:
   746             s.encode(p)
   746             s.encode(p)
   747     timer(d)
   747     timer(d)
   748     fm.end()
   748     fm.end()
   749 
   749 
   750 @command('perfbdiff', revlogopts + formatteropts, '-c|-m|FILE REV')
   750 @command('perfbdiff', revlogopts + formatteropts + [
   751 def perfbdiff(ui, repo, file_, rev=None, **opts):
   751     ('', 'count', 1, 'number of revisions to test (when using --startrev)')],
   752     """benchmark a bdiff between a revision and its delta parent"""
   752     '-c|-m|FILE REV')
       
   753 def perfbdiff(ui, repo, file_, rev=None, count=None, **opts):
       
   754     """benchmark a bdiff between revisions
       
   755 
       
   756     By default, benchmark a bdiff between its delta parent and itself.
       
   757 
       
   758     With ``--count``, benchmark bdiffs between delta parents and self for N
       
   759     revisions starting at the specified revision.
       
   760     """
   753     if opts.get('changelog') or opts.get('manifest'):
   761     if opts.get('changelog') or opts.get('manifest'):
   754         file_, rev = None, file_
   762         file_, rev = None, file_
   755     elif rev is None:
   763     elif rev is None:
   756         raise error.CommandError('perfbdiff', 'invalid arguments')
   764         raise error.CommandError('perfbdiff', 'invalid arguments')
   757 
   765 
   758     textpairs = []
   766     textpairs = []
   759 
   767 
   760     r = cmdutil.openrevlog(repo, 'perfbdiff', file_, opts)
   768     r = cmdutil.openrevlog(repo, 'perfbdiff', file_, opts)
   761 
   769 
   762     node = r.lookup(rev)
   770     startrev = r.rev(r.lookup(rev))
   763     rev = r.rev(node)
   771     for rev in range(startrev, min(startrev + count, len(r) - 1)):
   764     dp = r.deltaparent(rev)
   772         dp = r.deltaparent(rev)
   765     textpairs.append((r.revision(dp), r.revision(node)))
   773         textpairs.append((r.revision(dp), r.revision(rev)))
   766 
   774 
   767     def d():
   775     def d():
   768         for pair in textpairs:
   776         for pair in textpairs:
   769             bdiff.bdiff(*pair)
   777             bdiff.bdiff(*pair)
   770 
   778