11use 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 } ;
43
5- criterion_group ! ( benches, empty_archetypes) ;
6- criterion_main ! ( benches) ;
4+ criterion_group ! ( empty_archetypes_benches, empty_archetypes) ;
75
86#[ derive( Component ) ]
97struct A < const N : u16 > ( f32 ) ;
@@ -47,13 +45,12 @@ fn for_each(
4745 & A < 12 > ,
4846 ) > ,
4947) {
50- query. for_each ( |comp| {
48+ query. iter ( ) . for_each ( |comp| {
5149 black_box ( comp) ;
5250 } ) ;
5351}
5452
5553fn par_for_each (
56- task_pool : Res < ComputeTaskPool > ,
5754 query : Query < (
5855 & A < 0 > ,
5956 & A < 1 > ,
@@ -70,25 +67,26 @@ fn par_for_each(
7067 & A < 12 > ,
7168 ) > ,
7269) {
73- query. par_for_each ( & * task_pool , 64 , |comp| {
70+ query. par_iter ( ) . for_each ( |comp| {
7471 black_box ( comp) ;
7572 } ) ;
7673}
7774
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+ ) ]
7879fn setup ( parallel : bool , setup : impl FnOnce ( & mut Schedule ) ) -> ( World , Schedule ) {
79- let mut world = World :: new ( ) ;
80+ let world = World :: new ( ) ;
8081 let mut schedule = Schedule :: default ( ) ;
81- if parallel {
82- world. insert_resource ( ComputeTaskPool ( TaskPool :: default ( ) ) ) ;
83- }
8482 setup ( & mut schedule) ;
8583 ( world, schedule)
8684}
8785
8886/// create `count` entities with distinct archetypes
8987fn add_archetypes ( world : & mut World , count : u16 ) {
9088 for i in 0 ..count {
91- let mut e = world. spawn ( ) ;
89+ let mut e = world. spawn_empty ( ) ;
9290 e. insert ( A :: < 0 > ( 1.0 ) ) ;
9391 e. insert ( A :: < 1 > ( 1.0 ) ) ;
9492 e. insert ( A :: < 2 > ( 1.0 ) ) ;
@@ -158,7 +156,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
158156 } ) ;
159157 add_archetypes ( & mut world, archetype_count) ;
160158 world. clear_entities ( ) ;
161- let mut e = world. spawn ( ) ;
159+ let mut e = world. spawn_empty ( ) ;
162160 e. insert ( A :: < 0 > ( 1.0 ) ) ;
163161 e. insert ( A :: < 1 > ( 1.0 ) ) ;
164162 e. insert ( A :: < 2 > ( 1.0 ) ) ;
@@ -189,7 +187,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
189187 } ) ;
190188 add_archetypes ( & mut world, archetype_count) ;
191189 world. clear_entities ( ) ;
192- let mut e = world. spawn ( ) ;
190+ let mut e = world. spawn_empty ( ) ;
193191 e. insert ( A :: < 0 > ( 1.0 ) ) ;
194192 e. insert ( A :: < 1 > ( 1.0 ) ) ;
195193 e. insert ( A :: < 2 > ( 1.0 ) ) ;
@@ -220,7 +218,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
220218 } ) ;
221219 add_archetypes ( & mut world, archetype_count) ;
222220 world. clear_entities ( ) ;
223- let mut e = world. spawn ( ) ;
221+ let mut e = world. spawn_empty ( ) ;
224222 e. insert ( A :: < 0 > ( 1.0 ) ) ;
225223 e. insert ( A :: < 1 > ( 1.0 ) ) ;
226224 e. insert ( A :: < 2 > ( 1.0 ) ) ;
0 commit comments