Which one is more accurate in between time.clock() vs. time.time()?

Use time.clock() for timing/benchmarking if you need to choose between time and clock in Python.

time() returns the the seconds since the epoch, in UTC, as a floating point number on all platforms. On Unix time.clock() measures the amount of CPU time that has been used by the current process, so it's no good for measuring elapsed time from some point in the past. On Windows it will measure wall-clock seconds elapsed since the first call to the function.

Changing the system time affects time.time() but not time.clock().

If you're timing the execution of a block of code for benchmarking/profiling purposes, you should instead use the timeit module.

Updated on: 30-Jul-2019


Kickstart Your Career

Get certified by completing the course

Get Started