Python3 time clock () method
description
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)
grammar
clock () method syntax:
time.clock()
parameter
- 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.
Examples
The following example shows the clock () function to use:
#!/usr/bin/python3 import time def procedure(): time.sleep(2.5) # time.clock t0 = time.clock() procedure() print (time.clock() - t0) # time.time t0 = time.time() procedure() print (time.time() - t0)
The above example output is:
5.000000000000143e-05 2.5020556449890137