Skip to content

bench.h: fix getsec() double time conversion on Apple Silicon#5842

Merged
martin-frbg merged 1 commit into
OpenMathLib:developfrom
artem-dmitriev:patch-1
Jun 20, 2026
Merged

bench.h: fix getsec() double time conversion on Apple Silicon#5842
martin-frbg merged 1 commit into
OpenMathLib:developfrom
artem-dmitriev:patch-1

Conversation

@artem-dmitriev

Copy link
Copy Markdown
Contributor

On Apple Silicon, begin()/end() use clock_gettime_nsec_np(CLOCK_UPTIME_RAW), which already returns nanoseconds. getsec() then also multiplies by mach_timebase_info numer/denom — a conversion only valid for raw mach_absolute_time() ticks. On M-series numer/denom = 125/3, so every benchmark reports time ~41.67x too high (MFlops ~41.67x too low).

Repro (M-series): sleep 0.5s between begin()/end(), getsec() returns ~20.9s.

Drop the timebase scaling in the APPLE branch.

@martin-frbg

Copy link
Copy Markdown
Collaborator

Oops,looks like I conflated information gathered from the net, back when I didn't have access to M hardware.

@martin-frbg martin-frbg added this to the 0.3.34 milestone Jun 20, 2026
@martin-frbg martin-frbg merged commit 6773c85 into OpenMathLib:develop Jun 20, 2026
99 of 103 checks passed
@artem-dmitriev artem-dmitriev deleted the patch-1 branch June 20, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants