Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add block_box to benches #342

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

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

#[derive(Clone)]
struct Position(f32);
Expand Down Expand Up @@ -120,7 +121,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 +133,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 +178,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 +192,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 +204,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 +214,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 +226,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