Sunday, March 11, 2018

Time clock() Method


Time clock() Method in Python 3


The method clock() returns the current processor time as a floating point number
expressed in seconds on Unix. The precision depends on that of the C function of the same name, but in any case, this is the function to use for benchmarking Python or timing algorithms.

On Windows, this function returns wall-clock seconds elapsed since the first call to this function, as a floating point number, based on the Win32 function QueryPerformanceCounter.


Syntax                           
time.clock()


Return Value
This method returns the current processor time as a floating point number expressed in seconds on Unix and in Windows it returns wall-clock seconds elapsed since the first call to this function, as a floating point number.


Example :

and the output is :



Note: Not all systems can measure the true process time. On such systems (including Windows), clock usually measures the wall time since the program was started.