contrib/perf.py
changeset 7872 f680a1bd679b
parent 7366 eb240755386d
child 8656 284fda4cd093
equal deleted inserted replaced
7871:cdbe19abd1c5 7872:f680a1bd679b
     1 # perf.py - performance test routines
     1 # perf.py - performance test routines
     2 
     2 
     3 from mercurial.i18n import _
     3 from mercurial.i18n import _
     4 from mercurial import cmdutil, match
     4 from mercurial import cmdutil, match, commands
     5 import time, os, sys
     5 import time, os, sys
     6 
     6 
     7 def timer(func):
     7 def timer(func):
     8     results = []
     8     results = []
     9     begin = time.time()
     9     begin = time.time()
    99     timer(d)
    99     timer(d)
   100 
   100 
   101 def perflookup(ui, repo, rev):
   101 def perflookup(ui, repo, rev):
   102     timer(lambda: len(repo.lookup(rev)))
   102     timer(lambda: len(repo.lookup(rev)))
   103 
   103 
       
   104 def perflog(ui, repo):
       
   105     ui.pushbuffer()
       
   106     timer(lambda: commands.log(ui, repo, rev=[], date='', user=''))
       
   107     ui.popbuffer()
       
   108 
       
   109 def perftemplating(ui, repo):
       
   110     ui.pushbuffer()
       
   111     timer(lambda: commands.log(ui, repo, rev=[], date='', user='',
       
   112                                template='{date|shortdate} [{rev}:{node|short}]'
       
   113                                ' {author|person}: {desc|firstline}\n'))
       
   114     ui.popbuffer()
       
   115 
   104 cmdtable = {
   116 cmdtable = {
   105     'perflookup': (perflookup, []),
   117     'perflookup': (perflookup, []),
   106     'perfparents': (perfparents, []),
   118     'perfparents': (perfparents, []),
   107     'perfstartup': (perfstartup, []),
   119     'perfstartup': (perfstartup, []),
   108     'perfstatus': (perfstatus, []),
   120     'perfstatus': (perfstatus, []),
   111     'perfindex': (perfindex, []),
   123     'perfindex': (perfindex, []),
   112     'perfheads': (perfheads, []),
   124     'perfheads': (perfheads, []),
   113     'perftags': (perftags, []),
   125     'perftags': (perftags, []),
   114     'perfdirstate': (perfdirstate, []),
   126     'perfdirstate': (perfdirstate, []),
   115     'perfdirstatedirs': (perfdirstate, []),
   127     'perfdirstatedirs': (perfdirstate, []),
       
   128     'perflog': (perflog, []),
       
   129     'perftemplating': (perftemplating, []),
   116 }
   130 }
   117 
   131