Skip to content

Commit

Permalink
perf(bench): for_each has much better vectorization compares to a pla…
Browse files Browse the repository at this point in the history
…in for loop
  • Loading branch information
SOF3 committed Oct 20, 2023
1 parent bad108e commit 197bbcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ name = "iter_entity_add"
harness = false

[profile.bench]
debug = true
lto = true
14 changes: 7 additions & 7 deletions benches/iter_entity_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ fn system_individual_add_system_chunked(
vz: system::ReadSimple<TestArch, VelocityZ>,
entities: system::EntityIterator<TestArch>,
) {
for (_, (px, py, pz, vx, vy, vz)) in
entities.entities_with_chunked((&mut px, &mut py, &mut pz, &vx, &vy, &vz))
{
px.0 += vx.0;
py.0 += vy.0;
pz.0 += vz.0;
}
entities.entities_with_chunked((&mut px, &mut py, &mut pz, &vx, &vy, &vz)).for_each(
|(_, (px, py, pz, vx, vy, vz))| {
px.0 += vx.0;
py.0 += vy.0;
pz.0 += vz.0;
},
)
}

#[dynec::comp(of = TestArch, required)]
Expand Down

0 comments on commit 197bbcd

Please sign in to comment.