@@ -3,7 +3,6 @@ use bevy::ecs::{
3
3
world:: World ,
4
4
} ;
5
5
use criterion:: { black_box, criterion_group, criterion_main, Criterion } ;
6
- use rand:: { rngs:: SmallRng , RngCore , SeedableRng } ;
7
6
8
7
criterion_group ! (
9
8
benches,
@@ -47,27 +46,24 @@ fn spawn_commands(criterion: &mut Criterion) {
47
46
let mut world = World :: default ( ) ;
48
47
let mut command_queue = CommandQueue :: default ( ) ;
49
48
50
- let mut rng = SmallRng :: seed_from_u64 ( 42 ) ;
51
- let mut rng_bool = || rng. next_u32 ( ) % 2 == 0 ;
52
-
53
49
bencher. iter ( || {
54
50
let mut commands = Commands :: new ( & mut command_queue, & world) ;
55
- for _ in 0 ..entity_count {
51
+ for i in 0 ..entity_count {
56
52
let mut entity = commands. spawn ( ) ;
57
53
58
- if rng_bool ( ) {
54
+ if black_box ( i % 2 == 0 ) {
59
55
entity. insert ( A ) ;
60
56
}
61
57
62
- if rng_bool ( ) {
58
+ if black_box ( i % 3 == 0 ) {
63
59
entity. insert ( B ) ;
64
60
}
65
61
66
- if rng_bool ( ) {
62
+ if black_box ( i % 4 == 0 ) {
67
63
entity. insert ( C ) ;
68
64
}
69
65
70
- if rng_bool ( ) {
66
+ if black_box ( i % 5 == 0 ) {
71
67
entity. despawn ( ) ;
72
68
}
73
69
}
@@ -107,13 +103,10 @@ fn fake_commands(criterion: &mut Criterion) {
107
103
let mut world = World :: default ( ) ;
108
104
let mut command_queue = CommandQueue :: default ( ) ;
109
105
110
- let mut rng = SmallRng :: seed_from_u64 ( 42 ) ;
111
- let mut rng_bool = || rng. next_u32 ( ) % 2 == 0 ;
112
-
113
106
bencher. iter ( || {
114
107
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 )
117
110
commands. add ( FakeCommandA ) ;
118
111
} else {
119
112
commands. add ( FakeCommandB ( 0 ) ) ;
0 commit comments