Problem Description
ArtisanTime (src/artisanlib/time.py) is based on time.perf_counter():
def elapsed(self) -> float:
return (time.perf_counter() - self.clock)*self.base
That clock does not advance while the system is suspended:
- macOS:
perf_counter and monotonic both map to mach_absolute_time(), which stops during sleep (verified with time.get_clock_info('perf_counter') on macOS 26.6.2 / Python 3.14 → implementation='mach_absolute_time()')
- Windows:
QueryPerformanceCounter stops in S3 sleep
- Linux:
CLOCK_MONOTONIC excludes the time spent suspended (CLOCK_BOOTTIME does not)
All sample timestamps are derived from self.timeclock.elapsed() / elapsedMilli() in canvas.py, so if the computer is suspended while a recording is running, the suspended interval is missing from timex. The recorded roast appears shorter than it really was and everything after the gap sits at the wrong time. Nothing in the profile indicates this happened — the result simply looks plausible.
This is not hypothetical on laptops: a lid being closed cannot be inhibited by an application, and #2226 shows a machine suspending with Artisan left ON.
Steps To Reproduce
- Turn Artisan ON and START a recording.
- Send the computer to sleep for about 5 minutes (close the lid, or
pmset sleepnow on macOS).
- Wake the computer and let the recording continue, then STOP.
- The recorded roast time is about 5 minutes shorter than the elapsed wall clock time.
Possible directions
- Base the roast clock on a clock that keeps counting while suspended —
mach_continuous_time() on macOS (via ctypes), CLOCK_BOOTTIME on Linux, GetTickCount64() on Windows. Python offers no cross-platform continuous clock, so this needs a small per-platform helper. It changes what every recording measures.
- Keep the current clock and instead detect the suspension and warn the user and/or mark the affected profile.
The second is considerably cheaper, the first is arguably more correct. Which would the team prefer? I am happy to prepare a PR for whichever direction is wanted.
Artisan Version
4.2.1 (master); observed with the 4.2.0 release build
Computer OS and Version
macOS 26.6.2 (Apple Silicon); the analysis applies to Windows and Linux as well
Connected devices or roasting machine
Not device specific — affects any recording during which the computer is suspended
Files
Related: #2226 (connection lost across a system standby). PR #2225 detects system suspensions and logs a note about this effect, but deliberately does not touch the clock.
Problem Description
ArtisanTime(src/artisanlib/time.py) is based ontime.perf_counter():That clock does not advance while the system is suspended:
perf_counterandmonotonicboth map tomach_absolute_time(), which stops during sleep (verified withtime.get_clock_info('perf_counter')on macOS 26.6.2 / Python 3.14 →implementation='mach_absolute_time()')QueryPerformanceCounterstops in S3 sleepCLOCK_MONOTONICexcludes the time spent suspended (CLOCK_BOOTTIMEdoes not)All sample timestamps are derived from
self.timeclock.elapsed()/elapsedMilli()incanvas.py, so if the computer is suspended while a recording is running, the suspended interval is missing fromtimex. The recorded roast appears shorter than it really was and everything after the gap sits at the wrong time. Nothing in the profile indicates this happened — the result simply looks plausible.This is not hypothetical on laptops: a lid being closed cannot be inhibited by an application, and #2226 shows a machine suspending with Artisan left ON.
Steps To Reproduce
pmset sleepnowon macOS).Possible directions
mach_continuous_time()on macOS (via ctypes),CLOCK_BOOTTIMEon Linux,GetTickCount64()on Windows. Python offers no cross-platform continuous clock, so this needs a small per-platform helper. It changes what every recording measures.The second is considerably cheaper, the first is arguably more correct. Which would the team prefer? I am happy to prepare a PR for whichever direction is wanted.
Artisan Version
4.2.1 (master); observed with the 4.2.0 release build
Computer OS and Version
macOS 26.6.2 (Apple Silicon); the analysis applies to Windows and Linux as well
Connected devices or roasting machine
Not device specific — affects any recording during which the computer is suspended
Files
Related: #2226 (connection lost across a system standby). PR #2225 detects system suspensions and logs a note about this effect, but deliberately does not touch the clock.