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

PythonServer Side ProgrammingProgramming

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.

raja
Updated on 30-Jul-2019 22:30:21

Advertisements