Skip to content

Commit

Permalink
remove rng
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanSWard committed Jun 22, 2021
1 parent 4fb4af9 commit a2d543d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
1 change: 0 additions & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ edition = "2018"

[dev-dependencies]
criterion = "0.3"
rand = { version = "0.8.0", features = ["small_rng"] }
bevy = { path = "../" }

[[bench]]
Expand Down
21 changes: 7 additions & 14 deletions benches/benches/bevy_ecs/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use bevy::ecs::{
world::World,
};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rand::{rngs::SmallRng, RngCore, SeedableRng};

criterion_group!(
benches,
Expand Down Expand Up @@ -47,27 +46,24 @@ fn spawn_commands(criterion: &mut Criterion) {
let mut world = World::default();
let mut command_queue = CommandQueue::default();

let mut rng = SmallRng::seed_from_u64(42);
let mut rng_bool = || rng.next_u32() % 2 == 0;

bencher.iter(|| {
let mut commands = Commands::new(&mut command_queue, &world);
for _ in 0..entity_count {
for i in 0..entity_count {
let mut entity = commands.spawn();

if rng_bool() {
if black_box(i % 2 == 0) {
entity.insert(A);
}

if rng_bool() {
if black_box(i % 3 == 0) {
entity.insert(B);
}

if rng_bool() {
if black_box(i % 4 == 0) {
entity.insert(C);
}

if rng_bool() {
if black_box(i % 5 == 0) {
entity.despawn();
}
}
Expand Down Expand Up @@ -107,13 +103,10 @@ fn fake_commands(criterion: &mut Criterion) {
let mut world = World::default();
let mut command_queue = CommandQueue::default();

let mut rng = SmallRng::seed_from_u64(42);
let mut rng_bool = || rng.next_u32() % 2 == 0;

bencher.iter(|| {
let mut commands = Commands::new(&mut command_queue, &world);
for _ in 0..command_count {
if rng_bool() {
for i in 0..command_count {
if black_box(i % 2 == 0)
commands.add(FakeCommandA);
} else {
commands.add(FakeCommandB(0));
Expand Down

0 comments on commit a2d543d

Please sign in to comment.