comparison contrib/perf.py @ 30307:c8fa7ad1ff90

perf: add perfbdiff bdiff shows up a lot in profiling. I think it would be useful to have a perf command that runs bdiff over and over so we can find hot spots.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 05 Nov 2016 23:41:52 -0700
parents 3c8811efdddc
children 7d91a085ebe6
comparison
equal deleted inserted replaced
30306:5581b294f3c6 30307:c8fa7ad1ff90
23 import os 23 import os
24 import random 24 import random
25 import sys 25 import sys
26 import time 26 import time
27 from mercurial import ( 27 from mercurial import (
28 bdiff,
28 changegroup, 29 changegroup,
29 cmdutil, 30 cmdutil,
30 commands, 31 commands,
31 copies, 32 copies,
32 error, 33 error,
744 for p in s.fncache.entries: 745 for p in s.fncache.entries:
745 s.encode(p) 746 s.encode(p)
746 timer(d) 747 timer(d)
747 fm.end() 748 fm.end()
748 749
750 @command('perfbdiff', revlogopts + formatteropts, '-c|-m|FILE REV')
751 def perfbdiff(ui, repo, file_, rev=None, **opts):
752 """benchmark a bdiff between a revision and its delta parent"""
753 if opts.get('changelog') or opts.get('manifest'):
754 file_, rev = None, file_
755 elif rev is None:
756 raise error.CommandError('perfbdiff', 'invalid arguments')
757
758 r = cmdutil.openrevlog(repo, 'perfbdiff', file_, opts)
759
760 node = r.lookup(rev)
761 rev = r.rev(node)
762 dp = r.deltaparent(rev)
763
764 text1 = r.revision(dp)
765 text2 = r.revision(node)
766
767 def d():
768 bdiff.bdiff(text1, text2)
769
770 timer, fm = gettimer(ui, opts)
771 timer(d)
772 fm.end()
773
749 @command('perfdiffwd', formatteropts) 774 @command('perfdiffwd', formatteropts)
750 def perfdiffwd(ui, repo, **opts): 775 def perfdiffwd(ui, repo, **opts):
751 """Profile diff of working directory changes""" 776 """Profile diff of working directory changes"""
752 timer, fm = gettimer(ui, opts) 777 timer, fm = gettimer(ui, opts)
753 options = { 778 options = {