Show More
@@ -55,17 +55,15 b' except ImportError:' | |||
|
55 | 55 | import mercurial.util |
|
56 | 56 | import mercurial.dispatch |
|
57 | 57 | |
|
58 | import time | |
|
59 | ||
|
60 | 58 | def timer(func, title=None): |
|
61 | 59 | results = [] |
|
62 |
begin = |
|
|
60 | begin = mercurial.util.timer() | |
|
63 | 61 | count = 0 |
|
64 | 62 | while True: |
|
65 | 63 | ostart = os.times() |
|
66 |
cstart = |
|
|
64 | cstart = mercurial.util.timer() | |
|
67 | 65 | r = func() |
|
68 |
cstop = |
|
|
66 | cstop = mercurial.util.timer() | |
|
69 | 67 | ostop = os.times() |
|
70 | 68 | count += 1 |
|
71 | 69 | a, b = ostart, ostop |
@@ -190,13 +190,13 b' def stub_timer(fm, func, title=None):' | |||
|
190 | 190 | |
|
191 | 191 | def _timer(fm, func, title=None): |
|
192 | 192 | results = [] |
|
193 |
begin = |
|
|
193 | begin = util.timer() | |
|
194 | 194 | count = 0 |
|
195 | 195 | while True: |
|
196 | 196 | ostart = os.times() |
|
197 |
cstart = |
|
|
197 | cstart = util.timer() | |
|
198 | 198 | r = func() |
|
199 |
cstop = |
|
|
199 | cstop = util.timer() | |
|
200 | 200 | ostop = os.times() |
|
201 | 201 | count += 1 |
|
202 | 202 | a, b = ostart, ostop |
@@ -9,7 +9,6 b' from __future__ import absolute_import' | |||
|
9 | 9 | |
|
10 | 10 | import array |
|
11 | 11 | import struct |
|
12 | import time | |
|
13 | 12 | |
|
14 | 13 | from .node import ( |
|
15 | 14 | bin, |
@@ -21,6 +20,7 b' from . import (' | |||
|
21 | 20 | encoding, |
|
22 | 21 | error, |
|
23 | 22 | scmutil, |
|
23 | util, | |
|
24 | 24 | ) |
|
25 | 25 | |
|
26 | 26 | array = array.array |
@@ -261,7 +261,7 b' class branchcache(dict):' | |||
|
261 | 261 | missing heads, and a generator of nodes that are strictly a superset of |
|
262 | 262 | heads missing, this function updates self to be correct. |
|
263 | 263 | """ |
|
264 |
starttime = |
|
|
264 | starttime = util.timer() | |
|
265 | 265 | cl = repo.changelog |
|
266 | 266 | # collect new branch entries |
|
267 | 267 | newbranches = {} |
@@ -314,7 +314,7 b' class branchcache(dict):' | |||
|
314 | 314 | self.tiprev = tiprev |
|
315 | 315 | self.filteredhash = scmutil.filteredhash(repo, self.tiprev) |
|
316 | 316 | |
|
317 |
duration = |
|
|
317 | duration = util.timer() - starttime | |
|
318 | 318 | repo.ui.log('branchcache', 'updated %s branch cache in %.4f seconds\n', |
|
319 | 319 | repo.filtername, duration) |
|
320 | 320 |
@@ -123,7 +123,7 b' def dispatch(req):' | |||
|
123 | 123 | return -1 |
|
124 | 124 | |
|
125 | 125 | msg = ' '.join(' ' in a and repr(a) or a for a in req.args) |
|
126 |
starttime = |
|
|
126 | starttime = util.timer() | |
|
127 | 127 | ret = None |
|
128 | 128 | try: |
|
129 | 129 | ret = _runcatch(req) |
@@ -135,7 +135,7 b' def dispatch(req):' | |||
|
135 | 135 | raise |
|
136 | 136 | ret = -1 |
|
137 | 137 | finally: |
|
138 |
duration = |
|
|
138 | duration = util.timer() - starttime | |
|
139 | 139 | req.ui.flush() |
|
140 | 140 | req.ui.log("commandfinish", "%s exited %s after %0.2f seconds\n", |
|
141 | 141 | msg, ret or 0, duration) |
@@ -9,7 +9,6 b' from __future__ import absolute_import' | |||
|
9 | 9 | |
|
10 | 10 | import os |
|
11 | 11 | import sys |
|
12 | import time | |
|
13 | 12 | |
|
14 | 13 | from .i18n import _ |
|
15 | 14 | from . import ( |
@@ -88,7 +87,7 b' def _pythonhook(ui, repo, name, hname, f' | |||
|
88 | 87 | % (hname, funcname)) |
|
89 | 88 | |
|
90 | 89 | ui.note(_("calling hook %s: %s\n") % (hname, funcname)) |
|
91 |
starttime = |
|
|
90 | starttime = util.timer() | |
|
92 | 91 | |
|
93 | 92 | try: |
|
94 | 93 | r = obj(ui=ui, repo=repo, hooktype=name, **args) |
@@ -106,7 +105,7 b' def _pythonhook(ui, repo, name, hname, f' | |||
|
106 | 105 | ui.traceback() |
|
107 | 106 | return True, True |
|
108 | 107 | finally: |
|
109 |
duration = |
|
|
108 | duration = util.timer() - starttime | |
|
110 | 109 | ui.log('pythonhook', 'pythonhook-%s: %s finished in %0.2f seconds\n', |
|
111 | 110 | name, funcname, duration) |
|
112 | 111 | if r: |
@@ -118,7 +117,7 b' def _pythonhook(ui, repo, name, hname, f' | |||
|
118 | 117 | def _exthook(ui, repo, name, cmd, args, throw): |
|
119 | 118 | ui.note(_("running hook %s: %s\n") % (name, cmd)) |
|
120 | 119 | |
|
121 |
starttime = |
|
|
120 | starttime = util.timer() | |
|
122 | 121 | env = {} |
|
123 | 122 | |
|
124 | 123 | # make in-memory changes visible to external process |
@@ -145,7 +144,7 b' def _exthook(ui, repo, name, cmd, args, ' | |||
|
145 | 144 | cwd = pycompat.getcwd() |
|
146 | 145 | r = ui.system(cmd, environ=env, cwd=cwd) |
|
147 | 146 | |
|
148 |
duration = |
|
|
147 | duration = util.timer() - starttime | |
|
149 | 148 | ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n', |
|
150 | 149 | name, cmd, duration) |
|
151 | 150 | if r: |
@@ -8,7 +8,6 b'' | |||
|
8 | 8 | from __future__ import absolute_import, print_function |
|
9 | 9 | |
|
10 | 10 | import contextlib |
|
11 | import time | |
|
12 | 11 | |
|
13 | 12 | from .i18n import _ |
|
14 | 13 | from . import ( |
@@ -66,7 +65,7 b' def flameprofile(ui, fp):' | |||
|
66 | 65 | collapse_recursion = True |
|
67 | 66 | thread = flamegraph.ProfileThread(fp, 1.0 / freq, |
|
68 | 67 | filter_, collapse_recursion) |
|
69 |
start_time = |
|
|
68 | start_time = util.timer() | |
|
70 | 69 | try: |
|
71 | 70 | thread.start() |
|
72 | 71 | yield |
@@ -74,7 +73,7 b' def flameprofile(ui, fp):' | |||
|
74 | 73 | thread.stop() |
|
75 | 74 | thread.join() |
|
76 | 75 | print('Collected %d stack frames (%d unique) in %2.2f seconds.' % ( |
|
77 |
|
|
|
76 | util.timer() - start_time, thread.num_frames(), | |
|
78 | 77 | thread.num_frames(unique=True))) |
|
79 | 78 | |
|
80 | 79 | @contextlib.contextmanager |
@@ -12,7 +12,6 b' import errno' | |||
|
12 | 12 | import hashlib |
|
13 | 13 | import stat |
|
14 | 14 | import tempfile |
|
15 | import time | |
|
16 | 15 | |
|
17 | 16 | from .i18n import _ |
|
18 | 17 | from .node import short |
@@ -905,10 +904,10 b' def _upgraderepo(ui, srcrepo, dstrepo, r' | |||
|
905 | 904 | # the operation nearly instantaneous and atomic (at least in well-behaved |
|
906 | 905 | # environments). |
|
907 | 906 | ui.write(_('replacing store...\n')) |
|
908 |
tstart = |
|
|
907 | tstart = util.timer() | |
|
909 | 908 | util.rename(srcrepo.spath, backupvfs.join('store')) |
|
910 | 909 | util.rename(dstrepo.spath, srcrepo.spath) |
|
911 |
elapsed = |
|
|
910 | elapsed = util.timer() - tstart | |
|
912 | 911 | ui.write(_('store replacement complete; repository was inconsistent for ' |
|
913 | 912 | '%0.1fs\n') % elapsed) |
|
914 | 913 |
@@ -8,7 +8,6 b'' | |||
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import struct |
|
11 | import time | |
|
12 | 11 | |
|
13 | 12 | from .i18n import _ |
|
14 | 13 | from . import ( |
@@ -297,7 +296,7 b' def consumev1(repo, fp, filecount, bytec' | |||
|
297 | 296 | (filecount, util.bytecount(bytecount))) |
|
298 | 297 | handled_bytes = 0 |
|
299 | 298 | repo.ui.progress(_('clone'), 0, total=bytecount, unit=_('bytes')) |
|
300 |
start = |
|
|
299 | start = util.timer() | |
|
301 | 300 | |
|
302 | 301 | # TODO: get rid of (potential) inconsistency |
|
303 | 302 | # |
@@ -340,7 +339,7 b' def consumev1(repo, fp, filecount, bytec' | |||
|
340 | 339 | # streamclone-ed file at next access |
|
341 | 340 | repo.invalidate(clearfilecache=True) |
|
342 | 341 | |
|
343 |
elapsed = |
|
|
342 | elapsed = util.timer() - start | |
|
344 | 343 | if elapsed <= 0: |
|
345 | 344 | elapsed = 0.001 |
|
346 | 345 | repo.ui.progress(_('clone'), None) |
@@ -14,7 +14,6 b' from __future__ import absolute_import' | |||
|
14 | 14 | |
|
15 | 15 | import array |
|
16 | 16 | import errno |
|
17 | import time | |
|
18 | 17 | |
|
19 | 18 | from .node import ( |
|
20 | 19 | bin, |
@@ -344,7 +343,7 b' def _readtagcache(ui, repo):' | |||
|
344 | 343 | # potentially expensive search. |
|
345 | 344 | return ([], {}, valid, None, True) |
|
346 | 345 | |
|
347 |
starttime = |
|
|
346 | starttime = util.timer() | |
|
348 | 347 | |
|
349 | 348 | # Now we have to lookup the .hgtags filenode for every new head. |
|
350 | 349 | # This is the most expensive part of finding tags, so performance |
@@ -359,7 +358,7 b' def _readtagcache(ui, repo):' | |||
|
359 | 358 | |
|
360 | 359 | fnodescache.write() |
|
361 | 360 | |
|
362 |
duration = |
|
|
361 | duration = util.timer() - starttime | |
|
363 | 362 | ui.log('tagscache', |
|
364 | 363 | '%d/%d cache hits/lookups in %0.4f ' |
|
365 | 364 | 'seconds\n', |
@@ -2797,13 +2797,13 b' def timed(func):' | |||
|
2797 | 2797 | ''' |
|
2798 | 2798 | |
|
2799 | 2799 | def wrapper(*args, **kwargs): |
|
2800 |
start = time |
|
|
2800 | start = timer() | |
|
2801 | 2801 | indent = 2 |
|
2802 | 2802 | _timenesting[0] += indent |
|
2803 | 2803 | try: |
|
2804 | 2804 | return func(*args, **kwargs) |
|
2805 | 2805 | finally: |
|
2806 |
elapsed = time |
|
|
2806 | elapsed = timer() - start | |
|
2807 | 2807 | _timenesting[0] -= indent |
|
2808 | 2808 | stderr.write('%s%s: %s\n' % |
|
2809 | 2809 | (' ' * _timenesting[0], func.__name__, |
General Comments 0
You need to be logged in to leave comments.
Login now