Mercurial > hg
comparison contrib/hgperf @ 32054:616e788321cc stable 4.2-rc
freeze: merge default into stable for 4.2 code freeze
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 18 Apr 2017 12:24:34 -0400 |
parents | 22fbca1d11ed |
children | 78f644fdaa2a |
comparison
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: |