[New-bugs-announce] [issue41303] perf_counter result does not count system sleep time in Mac OS

nooB report at bugs.python.org
Wed Jul 15 08:43:19 EDT 2020


New submission from nooB <nsharish.mit at gmail.com>:

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_time".

-------------------------

import time
time.get_clock_info('perf_counter')
namespace(adjustable=False, implementation='mach_absolute_time()', monotonic=True, resolution=1e-09)

-------------------------

The documentation for "mach_absolute_time" clearly states that "this clock does not increment while the system is asleep"

https://developer.apple.com/documentation/kernel/1462446-mach_absolute_time


FWIW, Mac kernel does offer another function which returns monotonic ticks "including while the system is asleep"

https://developer.apple.com/documentation/kernel/1646199-mach_continuous_time

But it seems to be available only on Mac 10.12+.

----------
components: macOS
messages: 373690
nosy: ned.deily, nooB, ronaldoussoren
priority: normal
severity: normal
status: open
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41303>
_______________________________________


More information about the New-bugs-announce mailing list