Latest web development tutorials

Python3 time clock () method


Python time clock () function is the number of seconds to return the current floating-point computations of CPU time. Different procedures used to measure the time-consuming than time.time () more useful.

Note that this requires different meanings in different systems. On UNIX systems, it returns a "process of time", it is floating point (time stamp) in seconds. In WINDOWS, the first call, the return is the actual running time of the process. And called a second time after the first call since the running time now. (Actually a WIN32 on QueryPerformanceCounter (), based on more accurate than milliseconds)


clock () method syntax:



  • NA.

return value

This function has two functions,

In the first call, the return is the actual running time of the program;

To call a second time after the return is the time since the first call, the call to the interval

Under win32 system, this function returns the real time (wall time), while in Unix / Linux returns the CPU time.


The following example shows the clock () function to use:

import time

def procedure():

# time.clock
t0 = time.clock()
print (time.clock() - t0)

# time.time
t0 = time.time()
print (time.time() - t0)

The above example output is: