PEP 418: Fix clock_precision.py, time.monotonic() is not always present

This commit is contained in:
Victor Stinner 2012-04-18 00:39:03 +02:00
parent 38da45e1bb
commit 64a87deb1f
1 changed files with 5 additions and 1 deletions

View File

@ -36,7 +36,11 @@ def test_clock(name, func):
print("- precision in Python: %s" % format_duration(precision))
for name in ('clock', 'perf_counter', 'process_time', 'monotonic', 'time'):
clocks = ('clock', 'perf_counter', 'process_time')
if hasattr(time, 'monotonic'):
clocks.append('monotonic')
clocks.append('time')
for name in clocks:
func = getattr(time, name)
test_clock("%s()" % name, func)
info = time.get_clock_info(name)