Mercurial > public > mercurial-scm > hg
comparison mercurial/profiling.py @ 30975:22fbca1d11ed
mercurial: switch to util.timer for all interval timings
util.timer is now the best available interval timer, at the expense of not
having a known epoch. Let's use it whenever the epoch is irrelevant.
author | Simon Farnsworth <simonfar@fb.com> |
---|---|
date | Wed, 15 Feb 2017 13:17:39 -0800 |
parents | 517bc1cd7033 |
children | f40dc6f7c12f |
comparison
equal
deleted
inserted
replaced
30974:ae5d60bb70c9 | 30975:22fbca1d11ed |
---|---|
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from __future__ import absolute_import, print_function | 8 from __future__ import absolute_import, print_function |
9 | 9 |
10 import contextlib | 10 import contextlib |
11 import time | |
12 | 11 |
13 from .i18n import _ | 12 from .i18n import _ |
14 from . import ( | 13 from . import ( |
15 encoding, | 14 encoding, |
16 error, | 15 error, |
64 freq = ui.configint('profiling', 'freq', default=1000) | 63 freq = ui.configint('profiling', 'freq', default=1000) |
65 filter_ = None | 64 filter_ = None |
66 collapse_recursion = True | 65 collapse_recursion = True |
67 thread = flamegraph.ProfileThread(fp, 1.0 / freq, | 66 thread = flamegraph.ProfileThread(fp, 1.0 / freq, |
68 filter_, collapse_recursion) | 67 filter_, collapse_recursion) |
69 start_time = time.clock() | 68 start_time = util.timer() |
70 try: | 69 try: |
71 thread.start() | 70 thread.start() |
72 yield | 71 yield |
73 finally: | 72 finally: |
74 thread.stop() | 73 thread.stop() |
75 thread.join() | 74 thread.join() |
76 print('Collected %d stack frames (%d unique) in %2.2f seconds.' % ( | 75 print('Collected %d stack frames (%d unique) in %2.2f seconds.' % ( |
77 time.clock() - start_time, thread.num_frames(), | 76 util.timer() - start_time, thread.num_frames(), |
78 thread.num_frames(unique=True))) | 77 thread.num_frames(unique=True))) |
79 | 78 |
80 @contextlib.contextmanager | 79 @contextlib.contextmanager |
81 def statprofile(ui, fp): | 80 def statprofile(ui, fp): |
82 from . import statprof | 81 from . import statprof |