From 0e617b27085c0b8e3daa6b33d64cc3244b271f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Tue, 10 Oct 2023 00:11:22 +0200 Subject: [PATCH 1/3] foxes shouldn't march in sync --- examples/stress_tests/many_foxes.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/stress_tests/many_foxes.rs b/examples/stress_tests/many_foxes.rs index 194100658bd6e..c9ab18eed1f17 100644 --- a/examples/stress_tests/many_foxes.rs +++ b/examples/stress_tests/many_foxes.rs @@ -200,12 +200,12 @@ fn setup( fn setup_scene_once_loaded( animations: Res, foxes: Res, - mut player: Query<&mut AnimationPlayer>, + mut player: Query<(Entity, &mut AnimationPlayer)>, mut done: Local, ) { if !*done && player.iter().len() == foxes.count { - for mut player in &mut player { - player.play(animations.0[0].clone_weak()).repeat(); + for (entity, mut player) in &mut player { + player.play(animations.0[0].clone_weak()).repeat().seek_to(entity.index() as f32 / 10.0); } *done = true; } From c89a0b13291ba0c346ed667d695fe3ed0a842293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Tue, 10 Oct 2023 00:18:01 +0200 Subject: [PATCH 2/3] format --- examples/stress_tests/many_foxes.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/stress_tests/many_foxes.rs b/examples/stress_tests/many_foxes.rs index c9ab18eed1f17..bda8aa949dc70 100644 --- a/examples/stress_tests/many_foxes.rs +++ b/examples/stress_tests/many_foxes.rs @@ -205,7 +205,10 @@ fn setup_scene_once_loaded( ) { if !*done && player.iter().len() == foxes.count { for (entity, mut player) in &mut player { - player.play(animations.0[0].clone_weak()).repeat().seek_to(entity.index() as f32 / 10.0); + player + .play(animations.0[0].clone_weak()) + .repeat() + .seek_to(entity.index() as f32 / 10.0); } *done = true; } From 691b6b96ba70e518f3ba566b6a0b6278f422fe72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Tue, 10 Oct 2023 00:31:30 +0200 Subject: [PATCH 3/3] use argh for cli parameters --- examples/stress_tests/many_foxes.rs | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/examples/stress_tests/many_foxes.rs b/examples/stress_tests/many_foxes.rs index bda8aa949dc70..367b437cfbbe7 100644 --- a/examples/stress_tests/many_foxes.rs +++ b/examples/stress_tests/many_foxes.rs @@ -4,6 +4,7 @@ use std::f32::consts::PI; use std::time::Duration; +use argh::FromArgs; use bevy::{ diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, pbr::CascadeShadowConfigBuilder, @@ -11,14 +12,29 @@ use bevy::{ window::{PresentMode, WindowPlugin}, }; +#[derive(FromArgs, Resource)] +/// `many_foxes` stress test +struct Args { + /// wether all foxes run in sync. + #[argh(switch)] + sync: bool, + + /// total number of foxes. + #[argh(option, default = "1000")] + count: usize, +} + #[derive(Resource)] struct Foxes { count: usize, speed: f32, moving: bool, + sync: bool, } fn main() { + let args: Args = argh::from_env(); + App::new() .add_plugins(( DefaultPlugins.set(WindowPlugin { @@ -33,11 +49,10 @@ fn main() { LogDiagnosticsPlugin::default(), )) .insert_resource(Foxes { - count: std::env::args() - .nth(1) - .map_or(1000, |s| s.parse::().unwrap()), + count: args.count, speed: 2.0, moving: true, + sync: args.sync, }) .insert_resource(AmbientLight { color: Color::WHITE, @@ -205,10 +220,10 @@ fn setup_scene_once_loaded( ) { if !*done && player.iter().len() == foxes.count { for (entity, mut player) in &mut player { - player - .play(animations.0[0].clone_weak()) - .repeat() - .seek_to(entity.index() as f32 / 10.0); + player.play(animations.0[0].clone_weak()).repeat(); + if !foxes.sync { + player.seek_to(entity.index() as f32 / 10.0); + } } *done = true; }