diff --git a/benches/benches/bevy_ecs/benches.rs b/benches/benches/bevy_ecs/benches.rs index 1392536a7d..af5a38c963 100644 --- a/benches/benches/bevy_ecs/benches.rs +++ b/benches/benches/bevy_ecs/benches.rs @@ -5,6 +5,7 @@ mod events; mod fragmentation; mod iteration; mod observers; +mod param; mod scheduling; mod world; @@ -16,4 +17,5 @@ criterion_main!( observers::observer_benches, scheduling::scheduling_benches, world::world_benches, + param::param_benches, ); diff --git a/benches/benches/bevy_ecs/param/combinator_system.rs b/benches/benches/bevy_ecs/param/combinator_system.rs new file mode 100644 index 0000000000..5d15c30a72 --- /dev/null +++ b/benches/benches/bevy_ecs/param/combinator_system.rs @@ -0,0 +1,31 @@ +use bevy_ecs::prelude::*; +use criterion::Criterion; + +pub fn combinator_system(criterion: &mut Criterion) { + let mut world = World::new(); + let mut group = criterion.benchmark_group("param/combinator_system"); + + group.warm_up_time(core::time::Duration::from_millis(500)); + group.measurement_time(core::time::Duration::from_secs(3)); + + let mut schedule = Schedule::default(); + schedule.add_systems( + (|| {}) + .pipe(|| {}) + .pipe(|| {}) + .pipe(|| {}) + .pipe(|| {}) + .pipe(|| {}) + .pipe(|| {}) + .pipe(|| {}), + ); + // run once to initialize systems + schedule.run(&mut world); + group.bench_function("8_piped_systems", |bencher| { + bencher.iter(|| { + schedule.run(&mut world); + }); + }); + + group.finish(); +} diff --git a/benches/benches/bevy_ecs/param/dyn_param.rs b/benches/benches/bevy_ecs/param/dyn_param.rs new file mode 100644 index 0000000000..33de52bf13 --- /dev/null +++ b/benches/benches/bevy_ecs/param/dyn_param.rs @@ -0,0 +1,49 @@ +use bevy_ecs::{ + prelude::*, + system::{DynParamBuilder, DynSystemParam, ParamBuilder}, +}; +use criterion::Criterion; + +pub fn dyn_param(criterion: &mut Criterion) { + let mut world = World::new(); + let mut group = criterion.benchmark_group("param/combinator_system"); + + group.warm_up_time(core::time::Duration::from_millis(500)); + group.measurement_time(core::time::Duration::from_secs(3)); + + #[derive(Resource)] + struct R; + + let mut schedule = Schedule::default(); + let system = ( + DynParamBuilder::new::>(ParamBuilder), + DynParamBuilder::new::>(ParamBuilder), + DynParamBuilder::new::>(ParamBuilder), + DynParamBuilder::new::>(ParamBuilder), + DynParamBuilder::new::>(ParamBuilder), + DynParamBuilder::new::>(ParamBuilder), + DynParamBuilder::new::>(ParamBuilder), + DynParamBuilder::new::>(ParamBuilder), + ) + .build_state(&mut world) + .build_system( + |_: DynSystemParam, + _: DynSystemParam, + _: DynSystemParam, + _: DynSystemParam, + _: DynSystemParam, + _: DynSystemParam, + _: DynSystemParam, + _: DynSystemParam| {}, + ); + schedule.add_systems(system); + // run once to initialize systems + schedule.run(&mut world); + group.bench_function("8_dyn_params_system", |bencher| { + bencher.iter(|| { + schedule.run(&mut world); + }); + }); + + group.finish(); +} diff --git a/benches/benches/bevy_ecs/param/mod.rs b/benches/benches/bevy_ecs/param/mod.rs new file mode 100644 index 0000000000..20955fc29e --- /dev/null +++ b/benches/benches/bevy_ecs/param/mod.rs @@ -0,0 +1,11 @@ +use criterion::criterion_group; + +mod combinator_system; +mod dyn_param; +mod param_set; + +use combinator_system::*; +use dyn_param::*; +use param_set::*; + +criterion_group!(param_benches, combinator_system, dyn_param, param_set); diff --git a/benches/benches/bevy_ecs/param/param_set.rs b/benches/benches/bevy_ecs/param/param_set.rs new file mode 100644 index 0000000000..0521561b6b --- /dev/null +++ b/benches/benches/bevy_ecs/param/param_set.rs @@ -0,0 +1,36 @@ +use bevy_ecs::prelude::*; +use criterion::Criterion; + +pub fn param_set(criterion: &mut Criterion) { + let mut world = World::new(); + let mut group = criterion.benchmark_group("param/combinator_system"); + + group.warm_up_time(core::time::Duration::from_millis(500)); + group.measurement_time(core::time::Duration::from_secs(3)); + + #[derive(Resource)] + struct R; + + let mut schedule = Schedule::default(); + schedule.add_systems( + |_: ParamSet<( + ResMut, + ResMut, + ResMut, + ResMut, + ResMut, + ResMut, + ResMut, + ResMut, + )>| {}, + ); + // run once to initialize systems + schedule.run(&mut world); + group.bench_function("8_variant_param_set_system", |bencher| { + bencher.iter(|| { + schedule.run(&mut world); + }); + }); + + group.finish(); +} diff --git a/benches/benches/bevy_ecs/world/commands.rs b/benches/benches/bevy_ecs/world/commands.rs index ea220cf1ce..a1d7cdb09e 100644 --- a/benches/benches/bevy_ecs/world/commands.rs +++ b/benches/benches/bevy_ecs/world/commands.rs @@ -1,6 +1,5 @@ use bevy_ecs::{ component::Component, - entity::Entity, system::Commands, world::{Command, CommandQueue, World}, };