1
1
use bevy_ecs:: { component:: Component , prelude:: * , world:: World } ;
2
- use bevy_tasks:: { ComputeTaskPool , TaskPool } ;
3
- use criterion:: { black_box, criterion_group, criterion_main, BenchmarkId , Criterion } ;
2
+ use criterion:: { black_box, criterion_group, BenchmarkId , Criterion } ;
4
3
5
- criterion_group ! ( benches, empty_archetypes) ;
6
- criterion_main ! ( benches) ;
4
+ criterion_group ! ( empty_archetypes_benches, empty_archetypes) ;
7
5
8
6
#[ derive( Component ) ]
9
7
struct A < const N : u16 > ( f32 ) ;
@@ -47,13 +45,12 @@ fn for_each(
47
45
& A < 12 > ,
48
46
) > ,
49
47
) {
50
- query. for_each ( |comp| {
48
+ query. iter ( ) . for_each ( |comp| {
51
49
black_box ( comp) ;
52
50
} ) ;
53
51
}
54
52
55
53
fn par_for_each (
56
- task_pool : Res < ComputeTaskPool > ,
57
54
query : Query < (
58
55
& A < 0 > ,
59
56
& A < 1 > ,
@@ -70,25 +67,26 @@ fn par_for_each(
70
67
& A < 12 > ,
71
68
) > ,
72
69
) {
73
- query. par_for_each ( & * task_pool , 64 , |comp| {
70
+ query. par_iter ( ) . for_each ( |comp| {
74
71
black_box ( comp) ;
75
72
} ) ;
76
73
}
77
74
75
+ #[ expect(
76
+ unused_variables,
77
+ reason = "`parallel` has no effect, it needs to be removed or parallel support needs to be re-added."
78
+ ) ]
78
79
fn setup ( parallel : bool , setup : impl FnOnce ( & mut Schedule ) ) -> ( World , Schedule ) {
79
- let mut world = World :: new ( ) ;
80
+ let world = World :: new ( ) ;
80
81
let mut schedule = Schedule :: default ( ) ;
81
- if parallel {
82
- world. insert_resource ( ComputeTaskPool ( TaskPool :: default ( ) ) ) ;
83
- }
84
82
setup ( & mut schedule) ;
85
83
( world, schedule)
86
84
}
87
85
88
86
/// create `count` entities with distinct archetypes
89
87
fn add_archetypes ( world : & mut World , count : u16 ) {
90
88
for i in 0 ..count {
91
- let mut e = world. spawn ( ) ;
89
+ let mut e = world. spawn_empty ( ) ;
92
90
e. insert ( A :: < 0 > ( 1.0 ) ) ;
93
91
e. insert ( A :: < 1 > ( 1.0 ) ) ;
94
92
e. insert ( A :: < 2 > ( 1.0 ) ) ;
@@ -158,7 +156,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
158
156
} ) ;
159
157
add_archetypes ( & mut world, archetype_count) ;
160
158
world. clear_entities ( ) ;
161
- let mut e = world. spawn ( ) ;
159
+ let mut e = world. spawn_empty ( ) ;
162
160
e. insert ( A :: < 0 > ( 1.0 ) ) ;
163
161
e. insert ( A :: < 1 > ( 1.0 ) ) ;
164
162
e. insert ( A :: < 2 > ( 1.0 ) ) ;
@@ -189,7 +187,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
189
187
} ) ;
190
188
add_archetypes ( & mut world, archetype_count) ;
191
189
world. clear_entities ( ) ;
192
- let mut e = world. spawn ( ) ;
190
+ let mut e = world. spawn_empty ( ) ;
193
191
e. insert ( A :: < 0 > ( 1.0 ) ) ;
194
192
e. insert ( A :: < 1 > ( 1.0 ) ) ;
195
193
e. insert ( A :: < 2 > ( 1.0 ) ) ;
@@ -220,7 +218,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
220
218
} ) ;
221
219
add_archetypes ( & mut world, archetype_count) ;
222
220
world. clear_entities ( ) ;
223
- let mut e = world. spawn ( ) ;
221
+ let mut e = world. spawn_empty ( ) ;
224
222
e. insert ( A :: < 0 > ( 1.0 ) ) ;
225
223
e. insert ( A :: < 1 > ( 1.0 ) ) ;
226
224
e. insert ( A :: < 2 > ( 1.0 ) ) ;
0 commit comments