Fix <bitset>
benchmark correctness
#4817
Merged
+21
−10
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.
I see more things to do with
bitset
regarding performance, but first let's fix the current benchmark.Fortunately, the discovered issues didn't have impact on results, and on performance decisions.
Add
DoNotOptimize
to inputShould use this to prevent compiler making the benchmarked function or its part constant.
Currently the compiler doesn't do this, but it might improve in the future
Make 512 case as large
Small cases were initialized with
uint64_t
which was not enough to initialize 512 bit bitset.The 512 rows in the benchmark improved, but it is gooseberries vs watermelons: small cases have inner loop whereas large doesn't.
(The loop in small cases is to defeat branch prediction for the cases of branchy implementation activation. It is not needed for larger bitsets, as these would be vectorized, and if they wouldn't, the amount of bits should be enough to overflow the branch prediction)