From a variety of sources, notably here, we have:
time.clock() gives the best timer accuracy on Windows, while the time.time() function gives the best accuracy on Unix/Linux.
Additionally on non 'win32' systems time.clock() will measure application CPU time, which excludes time spent waiting for I/O while time.time() will measure 'absolute' time. On win32 time.clock() also measures CPU time.
If you want to time your code and get absolute times, do what timeit does:
time.clock() gives the best timer accuracy on Windows, while the time.time() function gives the best accuracy on Unix/Linux.
Additionally on non 'win32' systems time.clock() will measure application CPU time, which excludes time spent waiting for I/O while time.time() will measure 'absolute' time. On win32 time.clock() also measures CPU time.
If you want to time your code and get absolute times, do what timeit does:
if sys.platform == "win32": # On Windows, the best timer is time.clock() default_timer = time.clock else: # On most other platforms, the best timer is time.time() default_timer = time.time
Comments
Post a Comment