Skip to content

Commit

Permalink
Schedule-First: the new and improved add_systems (bevyengine#8079)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike <[email protected]>
  • Loading branch information
cart and hymm authored Mar 18, 2023
1 parent bca4b36 commit aefe1f0
Show file tree
Hide file tree
Showing 258 changed files with 2,120 additions and 2,741 deletions.
2 changes: 1 addition & 1 deletion benches/benches/bevy_ecs/components/archetype_updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn setup(system_count: usize) -> (World, Schedule) {
fn empty() {}
let mut schedule = Schedule::new();
for _ in 0..system_count {
schedule.add_system(empty);
schedule.add_systems(empty);
}
schedule.run(&mut world);
(world, schedule)
Expand Down
6 changes: 3 additions & 3 deletions benches/benches/bevy_ecs/empty_archetypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
let mut group = criterion.benchmark_group("empty_archetypes");
for archetype_count in [10, 100, 500, 1000, 2000, 5000, 10000] {
let (mut world, mut schedule) = setup(true, |schedule| {
schedule.add_system(iter);
schedule.add_systems(iter);
});
add_archetypes(&mut world, archetype_count);
world.clear_entities();
Expand Down Expand Up @@ -185,7 +185,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
}
for archetype_count in [10, 100, 500, 1000, 2000, 5000, 10000] {
let (mut world, mut schedule) = setup(true, |schedule| {
schedule.add_system(for_each);
schedule.add_systems(for_each);
});
add_archetypes(&mut world, archetype_count);
world.clear_entities();
Expand Down Expand Up @@ -216,7 +216,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
}
for archetype_count in [10, 100, 500, 1000, 2000, 5000, 10000] {
let (mut world, mut schedule) = setup(true, |schedule| {
schedule.add_system(par_for_each);
schedule.add_systems(par_for_each);
});
add_archetypes(&mut world, archetype_count);
world.clear_entities();
Expand Down
8 changes: 4 additions & 4 deletions benches/benches/bevy_ecs/scheduling/run_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn run_condition_yes(criterion: &mut Criterion) {
fn empty() {}
for amount in 0..21 {
let mut schedule = Schedule::new();
schedule.add_system(empty.run_if(yes));
schedule.add_systems(empty.run_if(yes));
for _ in 0..amount {
schedule.add_systems((empty, empty, empty, empty, empty).distributive_run_if(yes));
}
Expand All @@ -42,7 +42,7 @@ pub fn run_condition_no(criterion: &mut Criterion) {
fn empty() {}
for amount in 0..21 {
let mut schedule = Schedule::new();
schedule.add_system(empty.run_if(no));
schedule.add_systems(empty.run_if(no));
for _ in 0..amount {
schedule.add_systems((empty, empty, empty, empty, empty).distributive_run_if(no));
}
Expand Down Expand Up @@ -72,7 +72,7 @@ pub fn run_condition_yes_with_query(criterion: &mut Criterion) {
}
for amount in 0..21 {
let mut schedule = Schedule::new();
schedule.add_system(empty.run_if(yes_with_query));
schedule.add_systems(empty.run_if(yes_with_query));
for _ in 0..amount {
schedule.add_systems(
(empty, empty, empty, empty, empty).distributive_run_if(yes_with_query),
Expand Down Expand Up @@ -101,7 +101,7 @@ pub fn run_condition_yes_with_resource(criterion: &mut Criterion) {
}
for amount in 0..21 {
let mut schedule = Schedule::new();
schedule.add_system(empty.run_if(yes_with_resource));
schedule.add_systems(empty.run_if(yes_with_resource));
for _ in 0..amount {
schedule.add_systems(
(empty, empty, empty, empty, empty).distributive_run_if(yes_with_resource),
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/bevy_ecs/scheduling/running_systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn empty_systems(criterion: &mut Criterion) {
for amount in 0..5 {
let mut schedule = Schedule::new();
for _ in 0..amount {
schedule.add_system(empty);
schedule.add_systems(empty);
}
schedule.run(&mut world);
group.bench_function(&format!("{:03}_systems", amount), |bencher| {
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/scheduling/schedule.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy_app::App;
use bevy_app::{App, Update};
use bevy_ecs::prelude::*;
use criterion::Criterion;

Expand Down Expand Up @@ -72,7 +72,7 @@ pub fn build_schedule(criterion: &mut Criterion) {
group.measurement_time(std::time::Duration::from_secs(15));

// Method: generate a set of `graph_size` systems which have a One True Ordering.
// Add system to the schedule with full constraints. Hopefully this should be maximimally
// Add system to the schedule with full constraints. Hopefully this should be maximally
// difficult for bevy to figure out.
let labels: Vec<_> = (0..1000).map(|i| NumSet(i)).collect();

Expand All @@ -83,7 +83,7 @@ pub fn build_schedule(criterion: &mut Criterion) {
bencher.iter(|| {
let mut app = App::new();
for _ in 0..graph_size {
app.add_system(empty_system);
app.add_systems(Update, empty_system);
}
app.update();
});
Expand All @@ -93,7 +93,7 @@ pub fn build_schedule(criterion: &mut Criterion) {
group.bench_function(format!("{graph_size}_schedule"), |bencher| {
bencher.iter(|| {
let mut app = App::new();
app.add_system(empty_system.in_set(DummySet));
app.add_systems(Update, empty_system.in_set(DummySet));

// Build a fully-connected dependency graph describing the One True Ordering.
// Not particularly realistic but this can be refined later.
Expand All @@ -105,7 +105,7 @@ pub fn build_schedule(criterion: &mut Criterion) {
for label in &labels[i + 1..graph_size] {
sys = sys.before(*label);
}
app.add_system(sys);
app.add_systems(Update, sys);
}
// Run the app for a single frame.
// This is necessary since dependency resolution does not occur until the game runs.
Expand Down
9 changes: 4 additions & 5 deletions crates/bevy_animation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::ops::Deref;
use std::time::Duration;

use bevy_app::{App, CoreSet, Plugin};
use bevy_app::{App, Plugin, PostUpdate};
use bevy_asset::{AddAsset, Assets, Handle};
use bevy_core::Name;
use bevy_ecs::prelude::*;
Expand Down Expand Up @@ -550,10 +550,9 @@ impl Plugin for AnimationPlugin {
app.add_asset::<AnimationClip>()
.register_asset_reflect::<AnimationClip>()
.register_type::<AnimationPlayer>()
.add_system(
animation_player
.in_base_set(CoreSet::PostUpdate)
.before(TransformSystem::TransformPropagate),
.add_systems(
PostUpdate,
animation_player.before(TransformSystem::TransformPropagate),
);
}
}
Loading

0 comments on commit aefe1f0

Please sign in to comment.