-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancements for <bitset>
#3838
Conversation
Co-authored-by: A. Jiang <de34@live.cn>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The benchmark uses very predictable pattern. That would favor branchy code.
The branchy code would be somewhat better on a predictable pattern but a lot worse on a random pattern. So for a general purpose, branchless is better.
I didn't look into compiler output but I guess this change made code branchy. Please:
- Make the benchmark random
- If the random benchmark shows regression, get back to branchless code.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll validate and push changes! One moment...
benchmarks/src/bitset_to_string.cpp
Outdated
|
||
template <class charT> | ||
void BM_bitset_to_string_large_single(benchmark::State& state) { | ||
const auto large_bitset = bit_cast<bitset<CHAR_BIT * sizeof random_bits>>(random_bits); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No change requested: Technically, I don't believe that this is Standard. [bit.cast] is constrained for trivially copyable types, but [template.bitset] doesn't guarantee that for bitset
. That said, bit_cast
would refuse to compile otherwise, so I think we can get away with it.
Thanks! I also verified the benchmark results locally. 😻 |
I'm speculatively mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks for implementing these perf improvements and benchmarks! 📉 🎉 😺 |
bool operator[](size_t) const
._Members
private.to_string
.Benchmark
Result(release mode)
↓(Updated benchmark)
Benchmark
Result(release mode)