Skip to content

Commit

Permalink
Added performance warning when running stress test examples in debug …
Browse files Browse the repository at this point in the history
…mode (bevyengine#5029)

# Objective

Fixes bevyengine#5028

## Solution
Used #[cfg(debug_assertions)] to display a warning when running examples under stress_tests in debug mode
  • Loading branch information
Troels Jessen authored and james7132 committed Oct 28, 2022
1 parent 0b5cd30 commit dae0e06
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/stress_tests/README.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions examples/stress_tests/bevymark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ struct BirdTexture(Handle<Image>);
struct StatsText;

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
warn!(include_str!("warning_string.txt"));

let texture = asset_server.load("branding/icon.png");

commands.spawn_bundle(Camera2dBundle::default());
Expand Down
2 changes: 2 additions & 0 deletions examples/stress_tests/many_cubes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
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 }));
Expand Down
2 changes: 2 additions & 0 deletions examples/stress_tests/many_foxes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
foxes: Res<Foxes>,
) {
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"),
Expand Down
2 changes: 2 additions & 0 deletions examples/stress_tests/many_lights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
warn!(include_str!("warning_string.txt"));

const LIGHT_RADIUS: f32 = 0.3;
const LIGHT_INTENSITY: f32 = 5.0;
const RADIUS: f32 = 50.0;
Expand Down
2 changes: 2 additions & 0 deletions examples/stress_tests/many_sprites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ fn main() {
}

fn setup(mut commands: Commands, assets: Res<AssetServer>) {
warn!(include_str!("warning_string.txt"));

let mut rng = rand::thread_rng();

let tile_size = Vec2::splat(64.0);
Expand Down
3 changes: 3 additions & 0 deletions examples/stress_tests/transform_hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,10 @@ fn set_translation(translation: &mut Vec3, a: f32) {
}

fn setup(mut commands: Commands, cfg: Res<Cfg>) {
warn!(include_str!("warning_string.txt"));

let mut cam = Camera2dBundle::default();

cam.transform.translation.z = 100.0;
commands.spawn_bundle(cam);

Expand Down
1 change: 1 addition & 0 deletions examples/stress_tests/warning_string.txt
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit dae0e06

Please sign in to comment.