The time.perf_counter()
function is used for measuring system wide performance. The starting point of the performance time is set at the time when the interpreter started. It also takes into account any time adjustments made on the system, such as daylight saving time.
The perf_counter()
function is very useful for measuring the performance of a program, it offers a much higher resolution than other timing functions say the time.time()
function.
perf_counter()
copy
The function takes no argument
It returns a floating point value representing the elapsed seconds since the time when the interpreter started . It includes sleep durations such as during inputs, outputs, or delays due to time.sleep()
and similar
function calls.
import time print(time.perf_counter())
copy
Output:
6.3388505
In the above case, it means that 6.3388505
seconds have elapsed since the time when the interpreter started.
import time time.sleep(5) print(time.perf_counter())
copy
Output:
13.3388505