Skip to content

Correct iterator collection and partial-retention benchmarks - #597

Merged
alejandro-vaz merged 1 commit into
servo:v2from
astral-sh:charlie/codex-benchmark-coverage
Sep 9, 2026
Merged

Correct iterator collection and partial-retention benchmarks#597
alejandro-vaz merged 1 commit into
servo:v2from
astral-sh:charlie/codex-benchmark-coverage

Conversation

@charliermarsh

Copy link
Copy Markdown
Contributor

Summary

bench_from_iter currently measures conversion from a slice, and bench_retain_mut_half keeps every element because its input is filled with the even value 16.

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 SmallVec and the Vec controls.

Comment thread benches/bench.rs
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>(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that makes much more sense

Comment thread benches/bench.rs
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();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should pretty much be the same but I guess it doesn't really matter

@alejandro-vaz
alejandro-vaz added this pull request to the merge queue Sep 9, 2026
Merged via the queue into servo:v2 with commit ab03438 Sep 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants