One, two functions of the document:
1,time.time ():
-
- time. Time ( )
-
Return the time in seconds since the epoch as a floating point Number. Note that even though the time was always returned as a floating point number, not all systems provide time with a better p Recision than 1 second. While this function normally returns non-decreasing values, it can return a lower value than a previous call if the system Clock has been set back between the calls.
-
-
—————————————————————————————————————————————
-
-
-
- time. Time ( )
-
Returns the number of seconds since the era (1970.1.1). Although the return value of this function is always a floating-point number, not all system-supplied seconds will be accurate after the decimal point. In general, the return value of this function is not less than the return value it was called last time, unless the system clock resets between two calls.
-
2,time.clock ():
-
-
-
-
Time . Clock ( )
-
On Unix, return the current processor time as a floating point number expressed in seconds. The precision, and in fact the very definition of the meaning of "processor Time", depends on that of the C function of th E same name, but in any case, the "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 nu Mber, based on the Win32 function QueryPerformanceCounter (). The resolution is typically better than one microsecond.
-
-
-
-
—————————————————————————————————————————————
-
-
-
-
Time . Clock ( )
-
-
-
-
In Unix, the current processor time is returned in the form of a floating-point number in seconds. Its accuracy (accurately, "Processor Time" accuracy) depends on the C function of the same name, which, in any case, is a python ruler for time calculations.
-
-
Windows, the first call, returns the actual time that the process is running. The second subsequent call is the elapsed time since the first call to the present. (actually based on QueryPerformanceCounter () on WIN32, which is more accurate than milliseconds)
-
-
-
-
Two, usage and summary
-
-
1, in Windows, Time.clock () more accurate;
-
-
2, these two functions can not be mixed use;
(not to be continued)
Reference: Python Time Clock () method | Beginner's Tutorial
Follow the documentation Python (ii): Comparison and summary of Time.time () and Time.clock ()