Repository navigation
Allow TIMER accuracy below one millisecond - #798
Merged
grymmjack merged 1 commit intoOct 25, 2026
Merged
Conversation
TIMER(accuracy) always started from a whole number of milliseconds, so TIMER(.0001) or TIMER(.000001) could never be finer than 1 ms. That is too coarse for frame timing on high refresh rate displays (8.3 ms per frame at 120 Hz). The time is now read in microseconds. An accuracy finer than .001 uses it; TIMER, TIMER(.001) and coarser accuracies keep the exact whole millisecond value they returned before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a740g
approved these changes
Oct 24, 2026
SteveMcNeill
approved these changes
Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #797
TIMER(accuracy)always started from whole milliseconds, soTIMER(.000001)was never finer than 1 ms.Change (
internal/c/libqb/src/datetime.cpp)millis_since_midnight()becomesmicros_since_midnight().TIMER,TIMER(.001)and coarser accuracies usemicros / 1000, the same truncated millisecond value as before, so their results don't change.accuracy <= 0error check moved to the top so it still runs before the clock is read.Test
tests/compile_tests/timer/timer_sub_millisecond.baschecks four things:TIMER(.001)is still whole milliseconds.TIMER(.000001)has sub-millisecond digits.TIMER(.000001)never runs backwards (ignoring the midnight wrap).On
mainit fails with "only whole milliseconds"; with this change it passes.Tested on
timertest category passes.timertest category passes.The measured tick of
TIMER(.000001)is about 1 µs on all three. A smooth-motion test (ball moved inSUB _GLby elapsed time) that stuttered on a 120 Hz Mac withTIMER(.001)runs smoothly withTIMER(.000001)on all three.Docs: the wiki's TIMER page would need a line saying accuracies below .001 now work.
🤖 Generated with Claude Code