Mercurial > public > mercurial-scm > hg-stable
diff contrib/perf.py @ 31823:f6d77af84ef3
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
author | Philippe Pepiot <philippe.pepiot@logilab.fr> |
---|---|
date | Thu, 06 Apr 2017 14:41:42 +0200 |
parents | 413b44003462 |
children | ded48ad55146 |
line wrap: on
line diff
--- a/contrib/perf.py Wed Apr 05 15:31:08 2017 -0700 +++ b/contrib/perf.py Thu Apr 06 14:41:42 2017 +0200 @@ -67,6 +67,16 @@ 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 # 3.2 (or 7a7eed5176a4), even though formatting itself has been