Skip to content

fix: robust nanosecond timer parsing for non-GNU date#51

Open
Emeralddddd wants to merge 1 commit intonmhjklnm:masterfrom
Emeralddddd:fix/timer-compat
Open

fix: robust nanosecond timer parsing for non-GNU date#51
Emeralddddd wants to merge 1 commit intonmhjklnm:masterfrom
Emeralddddd:fix/timer-compat

Conversation

@Emeralddddd
Copy link
Copy Markdown

Summary

  • Extract _time_now() helper that validates date +%s%N output with regex instead of string length
  • Falls back to seconds-only on platforms where %N is literal (e.g. macOS)
  • Prevents arithmetic errors when _TIMER_START contains non-numeric suffixes

Test plan

  • Verify _timer_elapsed returns correct result on macOS (no GNU coreutils)
  • Verify _timer_elapsed returns millisecond precision on Linux
  • Run tests/timer_compat.sh if available

Extract _time_now() helper that validates date +%s%N output with regex
instead of string length, falling back to seconds-only on platforms
where %N is literal (e.g. macOS). Prevents arithmetic errors when
_TIMER_START contains non-numeric suffixes.
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.

1 participant