[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-07 Thread STINNER Victor
STINNER Victor added the comment: > For time.time in Windows, Python 3.10 should switch to using > GetSystemTimePreciseAsFileTime [3] instead of GetSystemTimeAsFileTime. It's already tracked by bpo-19007: "precise time.time() under Windows 8: use GetSystemTimePreciseAsFileTime". --

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-06 Thread Eryk Sun
Eryk Sun added the comment: > Does the same apply for time.monotonic? I would argue that the > difference in behavior between Linux/macOS and Windows is > unreasonable; given that time.monotonic exists for measuring time > intervals For time.monotonic in Windows, Python could switch to usin

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-06 Thread Rishav Kundu
Rishav Kundu added the comment: > perf_counter behavior during system suspend is undefined Does the same apply for time.monotonic? I would argue that the difference in behavior between Linux/macOS and Windows is unreasonable; given that time.monotonic exists for measuring time intervals (whic

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-06 Thread Rishav Kundu
Rishav Kundu added the comment: [1]: https://docs.python.org/3.8/library/time.html#time.clock_gettime [2]: https://developer.apple.com/documentation/kernel/1646199-mach_continuous_time effectively uses CLOCK_MONOTONIC_RAW on macOS. -- ___ Python

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-06 Thread STINNER Victor
STINNER Victor added the comment: > While I agree that the behavior of perf_counter should be consistent across > macOS/Linux and Windows wrt system suspend, perf_counter behavior during system suspend is undefined. -- ___ Python tracker

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-06 Thread Rishav Kundu
Rishav Kundu added the comment: While I agree that the behavior of perf_counter should be consistent across macOS/Linux and Windows wrt system suspend, you can already access those clocks by using time.clock_gettime [1] with appropriate clock IDs (CLOCK_MONOTONIC_RAW on macOS and CLOCK_BOOTT

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-06 Thread nooB
nooB added the comment: > 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 a

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-06 Thread Ronald Oussoren
Ronald Oussoren added the comment: mach_absolute_time returns time in ticks, there's a separate API that returns the resolution of this clock (which is already used). The manpage explicitly says that mach_absolute_time and CLOCK_UPTIME_RAW are the same clock: CLOCK_UPTIME_RAW clock t

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-06 Thread STINNER Victor
STINNER Victor added the comment: > On macOS CLOCK_UPTIME_RAW is the same as mach_absolute_time (according to the > manpage). https://developer.apple.com/documentation/kernel/1462446-mach_absolute_time says: "mach_absolute_time: Returns current value of a clock that increments monotonicall

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-05 Thread Ronald Oussoren
Ronald Oussoren added the comment: On macOS CLOCK_UPTIME_RAW is the same as mach_absolute_time (according to the manpage). -- ___ Python tracker ___ _

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-05 Thread STINNER Victor
STINNER Victor added the comment: > There is a clock with similar behaviour as the Linux clock: CLOCK_UPTIME_RAW On Linux, CLOCK_UPTIME_RAW is not adjusted by NTP and it should not be used for a clock using *seconds*. NTP ensures that a clock provides seconds and is not slower or faster. On

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-05 Thread Ronald Oussoren
Ronald Oussoren added the comment: @Nathaniel: I hadn't noticed that CLOCK_MONOTONIC on macOS behaves different from that clock on Linux. Sigh. That means there's little reason to switch to CLOCK_MONOTONIC on macOS, that would just result in different behaviour between Linux and macOS. The

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-05 Thread STINNER Victor
STINNER Victor added the comment: > (On which note: Please don't switch macOS to use > clock_gettime(CLOCK_MONOTONIC); that would be a breaking change for us!) Right, I propose to add new clock(s) since people may rely on the current clock(s) specifications. > At least Linux, macOS, FreeBSD

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-04 Thread Nathaniel Smith
Nathaniel Smith added the comment: I made a record of my investigations here: https://github.com/python-trio/trio/issues/1586 One reason we might care about this is that asyncio ought to be using a clock that stops ticking while suspended. (On which note: Please don't switch macOS to use c

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-04 Thread Joshua Bronson
Change by Joshua Bronson : -- nosy: +jab ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-04 Thread Rishav Kundu
Rishav Kundu added the comment: > Maybe a new clock is needed, clock which has a well defined behavior for > system suspend, on any platform. I’d like to work on this, if possible. Linux and macOS support seems to be straightforward. I will have to look into other platforms. What would be th

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-04 Thread STINNER Victor
STINNER Victor added the comment: > Or would a different API that distinguishes between clocks that track during > suspend versus those that not be a better idea? Given that at least macOS and > Linux offer both variants (not sure about Windows) I don't think that all platforms provide a clo

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-04 Thread Rishav Kundu
Rishav Kundu added the comment: Wouldn’t using mach_continuous_time (and its equivalents on other platforms) wherever possible be preferable? Or would a different API that distinguishes between clocks that track during suspend versus those that not be a better idea? Given that at least macOS

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-03 Thread STINNER Victor
STINNER Victor added the comment: perf_counter documentation says "It does include time elapsed during sleep and is system-wide." where "sleep" here means time.sleep(): https://docs.python.org/dev/library/time.html#time.perf_counter Python clock functions don't provide any warranty regarding

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-03 Thread Rishav Kundu
Change by Rishav Kundu : -- keywords: +patch nosy: +xrisk nosy_count: 6.0 -> 7.0 pull_requests: +20862 stage: -> patch review pull_request: https://github.com/python/cpython/pull/21719 ___ Python tracker ___

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-07-28 Thread Ronald Oussoren
Ronald Oussoren added the comment: macOS 10.12 also has clock_gettime(), which would allow using the generic code path (although the current path must be kept for older versions of macOS). -- ___ Python tracker

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-07-15 Thread Ned Deily
Change by Ned Deily : -- nosy: +belopolsky, p-ganssle, vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe

[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-07-15 Thread nooB
New submission from nooB : Documentation for time.perf_counter says "does include time elapsed during sleep". https://docs.python.org/3.8/library/time.html#time.perf_counter But it does not work as expected in Mac OS. I learnt that perf_counter uses the underlying c function: "mach_absolute_