mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
perf: add historical portability for util.timer
util.timer has been introduced in ae5d60bb and used in perf.py since 22fbca1d. For historical portability, forcibly define util.timer in perf.py
This commit is contained in:
parent
b6338c907a
commit
e5957f96bd
@ -66,6 +66,16 @@ def safehasattr(thing, attr):
|
||||
return getattr(thing, attr, _undefined) is not _undefined
|
||||
setattr(util, 'safehasattr', safehasattr)
|
||||
|
||||
# for "historical portability":
|
||||
# define util.timer forcibly, because util.timer has been available
|
||||
# since ae5d60bb70c9
|
||||
if safehasattr(time, 'perf_counter'):
|
||||
util.timer = time.perf_counter
|
||||
elif os.name == 'nt':
|
||||
util.timer = time.clock
|
||||
else:
|
||||
util.timer = time.time
|
||||
|
||||
# for "historical portability":
|
||||
# use locally defined empty option list, if formatteropts isn't
|
||||
# available, because commands.formatteropts has been available since
|
||||
|
@ -9,7 +9,7 @@ New errors are not allowed. Warnings are strongly discouraged.
|
||||
|
||||
$ hg locate -X contrib/python-zstandard -X hgext/fsmonitor/pywatchman |
|
||||
> sed 's-\\-/-g' | xargs "$check_code" --warnings --per-file=0 || false
|
||||
contrib/perf.py:859:
|
||||
contrib/perf.py:869:
|
||||
> r.revision(r.node(x))
|
||||
don't convert rev to node before passing to revision(nodeorrev)
|
||||
Skipping i18n/polib.py it has no-che?k-code (glob)
|
||||
|
@ -165,7 +165,7 @@ Check perf.py for historical portability
|
||||
$ (hg files -r 1.2 glob:mercurial/*.c glob:mercurial/*.py;
|
||||
> hg files -r tip glob:mercurial/*.c glob:mercurial/*.py) |
|
||||
> "$TESTDIR"/check-perf-code.py contrib/perf.py
|
||||
contrib/perf.py:859:
|
||||
contrib/perf.py:869:
|
||||
> r.revision(r.node(x))
|
||||
don't convert rev to node before passing to revision(nodeorrev)
|
||||
[1]
|
||||
|
Loading…
Reference in New Issue
Block a user