Correct iterator collection and partial-retention benchmarks - #597
Merged
alejandro-vaz merged 1 commit intoSep 9, 2026
Merged
Conversation
alejandro-vaz
self-requested a review
September 9, 2026 13:54
alejandro-vaz
approved these changes
Sep 9, 2026
| fn gen_retain_mut_half<V: Vector<u64>>(n: usize, b: &mut Bencher) { | ||
| b.iter_with_setup( | ||
| || V::from_elem(16, black_box(n)), | ||
| || (0..black_box(n) as u64).collect::<V>(), |
Collaborator
There was a problem hiding this comment.
that makes much more sense
| let v: Vec<u64> = (0..black_box(n)).collect(); | ||
| b.iter(|| { | ||
| let vec = V::from(black_box(&v)); | ||
| let vec: V = black_box(&v).iter().copied().collect(); |
Collaborator
There was a problem hiding this comment.
this should pretty much be the same but I guess it doesn't really matter
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.
Summary
bench_from_itercurrently measures conversion from a slice, andbench_retain_mut_halfkeeps every element because its input is filled with the even value16.We now collect a copied iterator in the collection benchmarks and use consecutive integers in the retention benchmarks, so the half-retention cases actually remove half the elements. This applies to both
SmallVecand theVeccontrols.