Skip to content

Commit

Permalink
fix benches
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoff3r committed Oct 3, 2024
1 parent 086c994 commit 74d2b1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions benches/benches/bevy_ecs/observers/propagation.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use bevy_ecs::{
component::Component,
entity::Entity,
event::Event,
observer::Trigger,
world::World,
component::Component, entity::Entity, event::Event, observer::Trigger, world::World,
};
use bevy_hierarchy::{BuildChildren, Parent};

Expand Down Expand Up @@ -110,15 +106,15 @@ fn add_listeners_to_hierarchy<const DENSITY: usize, const N: usize>(
world: &mut World,
) {
for e in roots.iter() {
world.entity_mut(*e).observe(empty_listener::<N>);
world.entity_mut(*e).observe_entity(empty_listener::<N>);
}
for e in leaves.iter() {
world.entity_mut(*e).observe(empty_listener::<N>);
world.entity_mut(*e).observe_entity(empty_listener::<N>);
}
let mut rng = deterministic_rand();
for e in nodes.iter() {
if rng.gen_bool(DENSITY as f64 / 100.0) {
world.entity_mut(*e).observe(empty_listener::<N>);
world.entity_mut(*e).observe_entity(empty_listener::<N>);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions benches/benches/bevy_ecs/observers/simple.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bevy_ecs::{entity::Entity, event::Event, observer::Trigger, world::World};

use criterion::{black_box, Criterion};
use rand::{prelude::SliceRandom, SeedableRng};
use rand::SeedableRng;
use rand_chacha::ChaCha8Rng;
fn deterministic_rand() -> ChaCha8Rng {
ChaCha8Rng::seed_from_u64(42)
Expand Down Expand Up @@ -29,7 +29,7 @@ pub fn observe_simple(criterion: &mut Criterion) {
let mut world = World::new();
let mut entities = vec![];
for _ in 0..10000 {
entities.push(world.spawn_empty().observe(empty_listener_base).id());
entities.push(world.spawn_empty().observe_entity(empty_listener_base).id());
}
entities.shuffle(&mut deterministic_rand());
bencher.iter(|| {
Expand Down

0 comments on commit 74d2b1b

Please sign in to comment.