contrib/hgperf
branchstable
changeset 32054 616e788321cc
parent 30975 22fbca1d11ed
child 33892 78f644fdaa2a
equal deleted inserted replaced
32053:52902059edc7 32054:616e788321cc
    53     sys.exit(-1)
    53     sys.exit(-1)
    54 
    54 
    55 import mercurial.util
    55 import mercurial.util
    56 import mercurial.dispatch
    56 import mercurial.dispatch
    57 
    57 
    58 import time
       
    59 
       
    60 def timer(func, title=None):
    58 def timer(func, title=None):
    61     results = []
    59     results = []
    62     begin = time.time()
    60     begin = mercurial.util.timer()
    63     count = 0
    61     count = 0
    64     while True:
    62     while True:
    65         ostart = os.times()
    63         ostart = os.times()
    66         cstart = time.time()
    64         cstart = mercurial.util.timer()
    67         r = func()
    65         r = func()
    68         cstop = time.time()
    66         cstop = mercurial.util.timer()
    69         ostop = os.times()
    67         ostop = os.times()
    70         count += 1
    68         count += 1
    71         a, b = ostart, ostop
    69         a, b = ostart, ostop
    72         results.append((cstop - cstart, b[0] - a[0], b[1]-a[1]))
    70         results.append((cstop - cstart, b[0] - a[0], b[1]-a[1]))
    73         if cstop - begin > 3 and count >= 100:
    71         if cstop - begin > 3 and count >= 100: