contrib/perf.py
changeset 14322 a90131b85fd8
parent 13277 9f707b297b0f
child 14494 1ffeeb91c55d
equal deleted inserted replaced
14321:003d63bb4fa5 14322:a90131b85fd8
     1 # perf.py - performance test routines
     1 # perf.py - performance test routines
     2 '''helper extension to measure performance'''
     2 '''helper extension to measure performance'''
     3 
     3 
     4 from mercurial import cmdutil, match, commands
     4 from mercurial import cmdutil, scmutil, match, commands
     5 import time, os, sys
     5 import time, os, sys
     6 
     6 
     7 def timer(func, title=None):
     7 def timer(func, title=None):
     8     results = []
     8     results = []
     9     begin = time.time()
     9     begin = time.time()
    29     sys.stderr.write("! wall %f comb %f user %f sys %f (best of %d)\n"
    29     sys.stderr.write("! wall %f comb %f user %f sys %f (best of %d)\n"
    30                      % (m[0], m[1] + m[2], m[1], m[2], count))
    30                      % (m[0], m[1] + m[2], m[1], m[2], count))
    31 
    31 
    32 def perfwalk(ui, repo, *pats):
    32 def perfwalk(ui, repo, *pats):
    33     try:
    33     try:
    34         m = cmdutil.match(repo, pats, {})
    34         m = scmutil.match(repo, pats, {})
    35         timer(lambda: len(list(repo.dirstate.walk(m, [], True, False))))
    35         timer(lambda: len(list(repo.dirstate.walk(m, [], True, False))))
    36     except:
    36     except:
    37         try:
    37         try:
    38             m = cmdutil.match(repo, pats, {})
    38             m = scmutil.match(repo, pats, {})
    39             timer(lambda: len([b for a, b, c in repo.dirstate.statwalk([], m)]))
    39             timer(lambda: len([b for a, b, c in repo.dirstate.statwalk([], m)]))
    40         except:
    40         except:
    41             timer(lambda: len(list(cmdutil.walk(repo, pats, {}))))
    41             timer(lambda: len(list(cmdutil.walk(repo, pats, {}))))
    42 
    42 
    43 def perfstatus(ui, repo, *pats):
    43 def perfstatus(ui, repo, *pats):