Skip to content

Commit b716d3d

Browse files
committed
remove rng
1 parent d221214 commit b716d3d

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

benches/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ edition = "2018"
99

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

1514
[[bench]]

benches/benches/bevy_ecs/commands.rs

+7-14
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use bevy::ecs::{
33
world::World,
44
};
55
use criterion::{black_box, criterion_group, criterion_main, Criterion};
6-
use rand::{rngs::SmallRng, RngCore, SeedableRng};
76

87
criterion_group!(
98
benches,
@@ -47,27 +46,24 @@ fn spawn_commands(criterion: &mut Criterion) {
4746
let mut world = World::default();
4847
let mut command_queue = CommandQueue::default();
4948

50-
let mut rng = SmallRng::seed_from_u64(42);
51-
let mut rng_bool = || rng.next_u32() % 2 == 0;
52-
5349
bencher.iter(|| {
5450
let mut commands = Commands::new(&mut command_queue, &world);
55-
for _ in 0..entity_count {
51+
for i in 0..entity_count {
5652
let mut entity = commands.spawn();
5753

58-
if rng_bool() {
54+
if black_box(i % 2 == 0) {
5955
entity.insert(A);
6056
}
6157

62-
if rng_bool() {
58+
if black_box(i % 3 == 0) {
6359
entity.insert(B);
6460
}
6561

66-
if rng_bool() {
62+
if black_box(i % 4 == 0) {
6763
entity.insert(C);
6864
}
6965

70-
if rng_bool() {
66+
if black_box(i % 5 == 0) {
7167
entity.despawn();
7268
}
7369
}
@@ -107,13 +103,10 @@ fn fake_commands(criterion: &mut Criterion) {
107103
let mut world = World::default();
108104
let mut command_queue = CommandQueue::default();
109105

110-
let mut rng = SmallRng::seed_from_u64(42);
111-
let mut rng_bool = || rng.next_u32() % 2 == 0;
112-
113106
bencher.iter(|| {
114107
let mut commands = Commands::new(&mut command_queue, &world);
115-
for _ in 0..command_count {
116-
if rng_bool() {
108+
for i in 0..command_count {
109+
if black_box(i % 2 == 0)
117110
commands.add(FakeCommandA);
118111
} else {
119112
commands.add(FakeCommandB(0));

0 commit comments

Comments
 (0)