Repository navigation
time: keep leading zeros in the fraction for time_type float - #5718
Merged
Merged
Conversation
Signed-off-by: og-orca <301901286+og-orca@users.noreply.github.com>
Watson1978
requested changes
Dec 3, 2026
Watson1978
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the fix. I ran the configuration from #5715 on master and on this branch. This branch writes all four times with 9 fraction digits. The new tests fail on master and pass here.
I have one request about speed. Please see the inline comment.
Signed-off-by: og-orca <301901286+og-orca@users.noreply.github.com>
Watson1978
approved these changes
Dec 3, 2026
Watson1978
left a comment
Contributor
There was a problem hiding this comment.
Thanks for applying the suggestion. I checked it again at 6c7f2e7. With the configuration from #5715, the out_file formatter writes all four times with 9 fraction digits, and test/test_time_formatter.rb passes. In the benchmark from my previous comment, NumericTimeFormatter#format now takes about the same time as on master (0.56 s and 0.54 s for 3 million calls with YJIT).
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.
Which issue(s) this PR fixes:
Fixes #5715
What this PR does / why we need it:
With
time_type float, theout_fileformatter dropped the fraction of a time when the fraction was under 0.1 second.1700000000.012345678came out as1700000000.0.The line in
format_floatwas meant to put zeros in front of the nanoseconds, but it replaced them with the zeros. Now it pads the nanoseconds withrjust(9, '0')only when they have fewer than 9 digits, so the fraction of anEventTimeor aTimealways has 9 digits.I ran the config from the issue on master and on this branch:
The new test has three times from the issue (the fourth,
.123456789, is covered by an existing test) plus 1 nanosecond. All four cases fail on master. I also timed 3 million calls toformatand it's about the same, 0.56 s now and 0.55 s before.Docs Changes:
None
Release Note:
time: keep leading zeros in the fraction for
time_type float, so that theout_fileformatter no longer drops a fraction under 0.1 second