Staging
v0.5.1
v0.5.1
https://github.com/python/cpython
Revision 64707923bef2f539c12446b880f715a70ed6c21a authored by Gregory P. Smith on 22 October 2015, 20:12:20 UTC, committed by Gregory P. Smith on 22 October 2015, 20:12:20 UTC
with what findCaller() does when running on non-POSIX platforms. (alternatively: the normcase calls in both places could be eliminated, but that touches more code and that refactoring hasn't even been done in 3 yet...)
1 parent 7427a79
Tip revision: 64707923bef2f539c12446b880f715a70ed6c21a authored by Gregory P. Smith on 22 October 2015, 20:12:20 UTC
Issue21709: Call os.path.normcase when setting _srcfile for compatibility
Issue21709: Call os.path.normcase when setting _srcfile for compatibility
Tip revision: 6470792
clockres.py
#!/usr/bin/env python
""" clockres - calculates the resolution in seconds of a given timer.
Copyright (c) 2006, Marc-Andre Lemburg (mal@egenix.com). See the
documentation for further information on copyrights, or contact
the author. All Rights Reserved.
"""
import time
TEST_TIME = 1.0
def clockres(timer):
d = {}
wallclock = time.time
start = wallclock()
stop = wallclock() + TEST_TIME
spin_loops = range(1000)
while 1:
now = wallclock()
if now >= stop:
break
for i in spin_loops:
d[timer()] = 1
values = d.keys()
values.sort()
min_diff = TEST_TIME
for i in range(len(values) - 1):
diff = values[i+1] - values[i]
if diff < min_diff:
min_diff = diff
return min_diff
if __name__ == '__main__':
print 'Clock resolution of various timer implementations:'
print 'time.clock: %10.3fus' % (clockres(time.clock) * 1e6)
print 'time.time: %10.3fus' % (clockres(time.time) * 1e6)
try:
import systimes
print 'systimes.processtime: %10.3fus' % (clockres(systimes.processtime) * 1e6)
except ImportError:
pass
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...