From a2d543d2c0ae28aa3589886c1491f9b0bd9edbe6 Mon Sep 17 00:00:00 2001 From: NathanSWard Date: Mon, 21 Jun 2021 20:52:31 -0600 Subject: [PATCH] remove rng --- benches/Cargo.toml | 1 - benches/benches/bevy_ecs/commands.rs | 21 +++++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 66f0f6ea8c1a4..3d13d202eff82 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -9,7 +9,6 @@ edition = "2018" [dev-dependencies] criterion = "0.3" -rand = { version = "0.8.0", features = ["small_rng"] } bevy = { path = "../" } [[bench]] diff --git a/benches/benches/bevy_ecs/commands.rs b/benches/benches/bevy_ecs/commands.rs index 5496a02dd0dcd..57ba249f581fa 100644 --- a/benches/benches/bevy_ecs/commands.rs +++ b/benches/benches/bevy_ecs/commands.rs @@ -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, @@ -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(); } } @@ -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));