Remove strlen in C++ benchmark#63
Merged
ulfjack merged 1 commit intoulfjack:masterfrom Aug 8, 2018
dtolnay:bench
Merged
Conversation
Avoiding strlen makes the benchmark more comparable across languages that would not want a null terminator, such as Rust. This strlen in bench32 was 20% of the iteration time on my machine.
StephanTLavavej
added a commit
to StephanTLavavej/ryu
that referenced
this pull request
Aug 7, 2018
Accepting ulfjack#63 will change bench32()'s timings (in a desirable way). That makes this a good time to simplify bench64() (changing its timings in a minor, neutral way). Instead of calling a 32-bit Mersenne Twister twice, which exactly replicated the previous third-party implementation, we can simply use the Standard's 64-bit Mersenne Twister. It generates every uint64_t with equal probability, so the test is essentially unaffected. (The exact values differ from the previous technique, so the timings might change very slightly, as if a different seed were chosen.) Calling std::mt19937 twice versus calling std::mt19937_64 once has somewhat different performance characteristics, but the benchmark doesn't time this, so it doesn't matter.
Owner
|
Thanks! Yeah, I remember that that was a large change in the 64-bit case. Weird that I missed updating the 32-bit case. shrug |
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.
Avoiding strlen makes the benchmark more comparable across languages that would not want a null terminator, such as Rust.
This strlen in bench32 was 20% of the iteration time on my machine.