Add criterion benchmarks #96
Open
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 was curious to quantify the performance of
SmolStr
inline strings vs naiveString
s. I wrote some criterion benchmarks for lengths 12, 50, 1000to see inline vs heap perf differences.I would expect inline SmolStrs to generally perform better than Strings, and heap SmolStrs to perform a little worse. However, the numbers seem generally worse almost everywhere exceptSmolStr::clone
. Can anyone comment on this and help me understand why this would be?Update: It seems the microbenches can be an easy place for the allocator to optimise, so I'll take a look elsewhere at improving a bench comparing allocating with non-allocating. Here we can just have some benches for this crate. I've stripped the benches to only being for this crate here.
Results