Skip to content

Commit

Permalink
Add block_box to benches
Browse files Browse the repository at this point in the history
  • Loading branch information
a1phyr committed Sep 21, 2023
1 parent 6b9d4ff commit a4f17e1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

use bencher::{benchmark_group, benchmark_main, Bencher};
use bencher::{benchmark_group, benchmark_main, black_box, Bencher};
use hecs::*;

#[derive(Clone)]
Expand Down Expand Up @@ -120,7 +120,7 @@ fn iterate_100k(b: &mut Bencher) {
}
b.iter(|| {
for (_, (pos, vel)) in &mut world.query::<(&mut Position, &Velocity)>() {
pos.0 += vel.0;
pos.0 += black_box(vel.0);
}
})
}
Expand All @@ -132,7 +132,7 @@ fn iterate_mut_100k(b: &mut Bencher) {
}
b.iter(|| {
for (_, (pos, vel)) in world.query_mut::<(&mut Position, &Velocity)>() {
pos.0 += vel.0;
pos.0 += black_box(vel.0);
}
})
}
Expand Down Expand Up @@ -177,7 +177,7 @@ fn iterate_uncached_100_by_50(b: &mut Bencher) {
spawn_100_by_50(&mut world);
b.iter(|| {
for (_, (pos, vel)) in world.query::<(&mut Position, &Velocity)>().iter() {
pos.0 += vel.0;
pos.0 += black_box(vel.0);
}
})
}
Expand All @@ -191,7 +191,7 @@ fn iterate_uncached_1_of_100_by_50(b: &mut Bencher) {
.with::<&[(); 0]>()
.iter()
{
pos.0 += vel.0;
pos.0 += black_box(vel.0);
}
})
}
Expand All @@ -203,7 +203,7 @@ fn iterate_cached_100_by_50(b: &mut Bencher) {
let _ = query.query(&world).iter();
b.iter(|| {
for (_, (pos, vel)) in query.query(&world).iter() {
pos.0 += vel.0;
pos.0 += black_box(vel.0);
}
})
}
Expand All @@ -213,7 +213,7 @@ fn iterate_mut_uncached_100_by_50(b: &mut Bencher) {
spawn_100_by_50(&mut world);
b.iter(|| {
for (_, (pos, vel)) in world.query_mut::<(&mut Position, &Velocity)>() {
pos.0 += vel.0;
pos.0 += black_box(vel.0);
}
})
}
Expand All @@ -225,7 +225,7 @@ fn iterate_mut_cached_100_by_50(b: &mut Bencher) {
let _ = query.query_mut(&mut world);
b.iter(|| {
for (_, (pos, vel)) in query.query_mut(&mut world) {
pos.0 += vel.0;
pos.0 += black_box(vel.0);
}
})
}
Expand Down

0 comments on commit a4f17e1

Please sign in to comment.