From b3d15153f3e913e7aef1518829c92da7ac2487c1 Mon Sep 17 00:00:00 2001 From: Troels Jessen Date: Wed, 13 Jul 2022 19:13:46 +0000 Subject: [PATCH] Added performance warning when running stress test examples in debug mode (#5029) # Objective Fixes #5028 ## Solution Used #[cfg(debug_assertions)] to display a warning when running examples under stress_tests in debug mode --- examples/stress_tests/README.md | 3 +++ examples/stress_tests/bevymark.rs | 2 ++ examples/stress_tests/many_cubes.rs | 2 ++ examples/stress_tests/many_foxes.rs | 2 ++ examples/stress_tests/many_lights.rs | 2 ++ examples/stress_tests/many_sprites.rs | 2 ++ examples/stress_tests/transform_hierarchy.rs | 3 +++ examples/stress_tests/warning_string.txt | 1 + 8 files changed, 17 insertions(+) create mode 100644 examples/stress_tests/README.md create mode 100644 examples/stress_tests/warning_string.txt diff --git a/examples/stress_tests/README.md b/examples/stress_tests/README.md new file mode 100644 index 0000000000..7bfef204a4 --- /dev/null +++ b/examples/stress_tests/README.md @@ -0,0 +1,3 @@ +# Stress tests + +These examples are used to stress test Bevy's performance in various ways. These should be run with the --release argument to cargo or equivalent optimization, otherwise they will be very slow. diff --git a/examples/stress_tests/bevymark.rs b/examples/stress_tests/bevymark.rs index c884d24f46..6fb85a5d8e 100644 --- a/examples/stress_tests/bevymark.rs +++ b/examples/stress_tests/bevymark.rs @@ -90,6 +90,8 @@ struct BirdTexture(Handle); struct StatsText; fn setup(mut commands: Commands, asset_server: Res) { + warn!(include_str!("warning_string.txt")); + let texture = asset_server.load("branding/icon.png"); commands.spawn_bundle(Camera2dBundle::default()); diff --git a/examples/stress_tests/many_cubes.rs b/examples/stress_tests/many_cubes.rs index 2e06788313..f1f6d9ba40 100644 --- a/examples/stress_tests/many_cubes.rs +++ b/examples/stress_tests/many_cubes.rs @@ -37,6 +37,8 @@ fn setup( mut meshes: ResMut>, mut materials: ResMut>, ) { + warn!(include_str!("warning_string.txt")); + const WIDTH: usize = 200; const HEIGHT: usize = 200; let mesh = meshes.add(Mesh::from(shape::Cube { size: 1.0 })); diff --git a/examples/stress_tests/many_foxes.rs b/examples/stress_tests/many_foxes.rs index d31b66da3b..4251354a5f 100644 --- a/examples/stress_tests/many_foxes.rs +++ b/examples/stress_tests/many_foxes.rs @@ -73,6 +73,8 @@ fn setup( mut materials: ResMut>, foxes: Res, ) { + warn!(include_str!("warning_string.txt")); + // Insert a resource with the current scene information commands.insert_resource(Animations(vec![ asset_server.load("models/animated/Fox.glb#Animation2"), diff --git a/examples/stress_tests/many_lights.rs b/examples/stress_tests/many_lights.rs index f172812526..0236980d56 100644 --- a/examples/stress_tests/many_lights.rs +++ b/examples/stress_tests/many_lights.rs @@ -35,6 +35,8 @@ fn setup( mut meshes: ResMut>, mut materials: ResMut>, ) { + warn!(include_str!("warning_string.txt")); + const LIGHT_RADIUS: f32 = 0.3; const LIGHT_INTENSITY: f32 = 5.0; const RADIUS: f32 = 50.0; diff --git a/examples/stress_tests/many_sprites.rs b/examples/stress_tests/many_sprites.rs index b475a2e1cf..7aecd3b424 100644 --- a/examples/stress_tests/many_sprites.rs +++ b/examples/stress_tests/many_sprites.rs @@ -33,6 +33,8 @@ fn main() { } fn setup(mut commands: Commands, assets: Res) { + warn!(include_str!("warning_string.txt")); + let mut rng = rand::thread_rng(); let tile_size = Vec2::splat(64.0); diff --git a/examples/stress_tests/transform_hierarchy.rs b/examples/stress_tests/transform_hierarchy.rs index 353dde16b9..8be19ccaaa 100644 --- a/examples/stress_tests/transform_hierarchy.rs +++ b/examples/stress_tests/transform_hierarchy.rs @@ -257,7 +257,10 @@ fn set_translation(translation: &mut Vec3, a: f32) { } fn setup(mut commands: Commands, cfg: Res) { + warn!(include_str!("warning_string.txt")); + let mut cam = Camera2dBundle::default(); + cam.transform.translation.z = 100.0; commands.spawn_bundle(cam); diff --git a/examples/stress_tests/warning_string.txt b/examples/stress_tests/warning_string.txt new file mode 100644 index 0000000000..e73537b166 --- /dev/null +++ b/examples/stress_tests/warning_string.txt @@ -0,0 +1 @@ +This is a stress test used to push Bevy to its limit and debug performance issues. It is not representative of an actual game. It must be run in release mode using --release or it will be very slow. \ No newline at end of file