Message374935
> perf_counter documentation says "It does include time elapsed during sleep and is system-wide." where "sleep" here means time.sleep()
Apologies for misinterpreting the documentation. A clock function that includes system suspend time can be useful. Consider this as a feature request.
I noticed that on both Linux and Mac OS, the functions time.monotonic and time.perf_counter are exactly same. They do not count time elapsed during suspend.
--- CODE -----
import time
for clock in "monotonic", "perf_counter":
print(f"{clock}: {time.get_clock_info(clock)}")
--- MAC OUTPUT ----
monotonic: namespace(adjustable=False, implementation='mach_absolute_time()', monotonic=True, resolution=1e-09)
perf_counter: namespace(adjustable=False, implementation='mach_absolute_time()', monotonic=True, resolution=1e-09)
--- LINUX OUTPUT --
monotonic: namespace(adjustable=False, implementation='clock_gettime(CLOCK_MONOTONIC)', monotonic=True, resolution=1e-09)
perf_counter: namespace(adjustable=False, implementation='clock_gettime(CLOCK_MONOTONIC)', monotonic=True, resolution=1e-09)
--------------
In Windows, perf_counter uses "QueryPerformanceCounter()" which includes "the time when the machine was in a sleep state such as standby, hibernate, or connected standby"
refer: https://docs.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps
I learnt that "mach_continuous_time()" in Mac OS, "clock_gettime(CLOCK_BOOTTIME)" in Linux and "QueryPerformanceCounter()" in Windows all include system suspend time. It would be nice if perf_counter can be tweaked to provide similar behaviour across platforms. If it is not recommended, the mentioned functions can be exposed as a separate clock function.
Thanks. |
|
Date |
User |
Action |
Args |
2020-08-06 13:50:59 | nooB | set | recipients:
+ nooB, ronaldoussoren, belopolsky, vstinner, ned.deily, njs, jab, p-ganssle, xrisk |
2020-08-06 13:50:58 | nooB | set | messageid: <1596721858.95.0.319388131764.issue41303@roundup.psfhosted.org> |
2020-08-06 13:50:58 | nooB | link | issue41303 messages |
2020-08-06 13:50:58 | nooB | create | |
|