Skip to content

Commit

Permalink
Use the Continuous update mode in stress tests when unfocused (#11652)
Browse files Browse the repository at this point in the history
# Objective

- When running any of the stress tests, the refresh rate is currently
capped to 60hz because of the `ReactiveLowPower` default used when the
window is not in focus. Since stress tests should run as fast as
possible (and as such vsync is disabled for all of them), it makes sense
to always run them in `Continuous` mode. This is especially useful to
avoid capturing non-representative frame times when recording a Tracy
frame.

## Solution

- Always use the `Continuous` update mode in stress tests.
  • Loading branch information
Kanabenki authored Feb 1, 2024
1 parent b1a2d34 commit e3cf5f8
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/stress_tests/bevymark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use bevy::{
sprite::{MaterialMesh2dBundle, Mesh2dHandle},
utils::Duration,
window::{PresentMode, WindowResolution},
winit::{UpdateMode, WinitSettings},
};
use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng};

Expand Down Expand Up @@ -115,6 +116,10 @@ fn main() {
FrameTimeDiagnosticsPlugin,
LogDiagnosticsPlugin::default(),
))
.insert_resource(WinitSettings {
focused_mode: UpdateMode::Continuous,
unfocused_mode: UpdateMode::Continuous,
})
.insert_resource(args)
.insert_resource(BevyCounter {
count: 0,
Expand Down
5 changes: 5 additions & 0 deletions examples/stress_tests/many_animated_sprites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use bevy::{
prelude::*,
render::camera::Camera,
window::{PresentMode, WindowResolution},
winit::{UpdateMode, WinitSettings},
};

use rand::Rng;
Expand All @@ -33,6 +34,10 @@ fn main() {
..default()
}),
))
.insert_resource(WinitSettings {
focused_mode: UpdateMode::Continuous,
unfocused_mode: UpdateMode::Continuous,
})
.add_systems(Startup, setup)
.add_systems(
Update,
Expand Down
5 changes: 5 additions & 0 deletions examples/stress_tests/many_buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
prelude::*,
window::{PresentMode, WindowPlugin, WindowResolution},
winit::{UpdateMode, WinitSettings},
};

const FONT_SIZE: f32 = 7.0;
Expand Down Expand Up @@ -62,6 +63,10 @@ fn main() {
FrameTimeDiagnosticsPlugin,
LogDiagnosticsPlugin::default(),
))
.insert_resource(WinitSettings {
focused_mode: UpdateMode::Continuous,
unfocused_mode: UpdateMode::Continuous,
})
.add_systems(Update, button_system);

if args.grid {
Expand Down
5 changes: 5 additions & 0 deletions examples/stress_tests/many_cubes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use bevy::{
render_resource::{Extent3d, TextureDimension, TextureFormat},
},
window::{PresentMode, WindowPlugin, WindowResolution},
winit::{UpdateMode, WinitSettings},
};
use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng};

Expand Down Expand Up @@ -86,6 +87,10 @@ fn main() {
FrameTimeDiagnosticsPlugin,
LogDiagnosticsPlugin::default(),
))
.insert_resource(WinitSettings {
focused_mode: UpdateMode::Continuous,
unfocused_mode: UpdateMode::Continuous,
})
.insert_resource(args)
.add_systems(Startup, setup)
.add_systems(Update, (move_camera, print_mesh_count))
Expand Down
5 changes: 5 additions & 0 deletions examples/stress_tests/many_foxes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use bevy::{
pbr::CascadeShadowConfigBuilder,
prelude::*,
window::{PresentMode, WindowPlugin, WindowResolution},
winit::{UpdateMode, WinitSettings},
};

#[derive(FromArgs, Resource)]
Expand Down Expand Up @@ -54,6 +55,10 @@ fn main() {
FrameTimeDiagnosticsPlugin,
LogDiagnosticsPlugin::default(),
))
.insert_resource(WinitSettings {
focused_mode: UpdateMode::Continuous,
unfocused_mode: UpdateMode::Continuous,
})
.insert_resource(Foxes {
count: args.count,
speed: 2.0,
Expand Down
5 changes: 5 additions & 0 deletions examples/stress_tests/many_gizmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use bevy::{
diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin},
prelude::*,
window::{PresentMode, WindowResolution},
winit::{UpdateMode, WinitSettings},
};

const SYSTEM_COUNT: u32 = 10;
Expand All @@ -22,6 +23,10 @@ fn main() {
}),
FrameTimeDiagnosticsPlugin,
))
.insert_resource(WinitSettings {
focused_mode: UpdateMode::Continuous,
unfocused_mode: UpdateMode::Continuous,
})
.insert_resource(Config {
line_count: 50_000,
fancy: false,
Expand Down
5 changes: 5 additions & 0 deletions examples/stress_tests/many_glyphs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use bevy::{
prelude::*,
text::{BreakLineOn, Text2dBounds},
window::{PresentMode, WindowPlugin, WindowResolution},
winit::{UpdateMode, WinitSettings},
};

fn main() {
Expand All @@ -26,6 +27,10 @@ fn main() {
FrameTimeDiagnosticsPlugin,
LogDiagnosticsPlugin::default(),
))
.insert_resource(WinitSettings {
focused_mode: UpdateMode::Continuous,
unfocused_mode: UpdateMode::Continuous,
})
.add_systems(Startup, setup);

if std::env::args().any(|arg| arg == "recompute-text") {
Expand Down
5 changes: 5 additions & 0 deletions examples/stress_tests/many_lights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use bevy::{
prelude::*,
render::{camera::ScalingMode, Render, RenderApp, RenderSet},
window::{PresentMode, WindowPlugin, WindowResolution},
winit::{UpdateMode, WinitSettings},
};
use rand::{thread_rng, Rng};

Expand All @@ -30,6 +31,10 @@ fn main() {
LogDiagnosticsPlugin::default(),
LogVisibleLights,
))
.insert_resource(WinitSettings {
focused_mode: UpdateMode::Continuous,
unfocused_mode: UpdateMode::Continuous,
})
.add_systems(Startup, setup)
.add_systems(Update, (move_camera, print_light_count))
.run();
Expand Down
5 changes: 5 additions & 0 deletions examples/stress_tests/many_sprites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
prelude::*,
window::{PresentMode, WindowPlugin, WindowResolution},
winit::{UpdateMode, WinitSettings},
};

use rand::Rng;
Expand Down Expand Up @@ -41,6 +42,10 @@ fn main() {
..default()
}),
))
.insert_resource(WinitSettings {
focused_mode: UpdateMode::Continuous,
unfocused_mode: UpdateMode::Continuous,
})
.add_systems(Startup, setup)
.add_systems(
Update,
Expand Down
5 changes: 5 additions & 0 deletions examples/stress_tests/text_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use bevy::{
prelude::*,
text::{BreakLineOn, Text2dBounds},
window::{PresentMode, WindowPlugin, WindowResolution},
winit::{UpdateMode, WinitSettings},
};

fn main() {
Expand All @@ -24,6 +25,10 @@ fn main() {
FrameTimeDiagnosticsPlugin,
LogDiagnosticsPlugin::default(),
))
.insert_resource(WinitSettings {
focused_mode: UpdateMode::Continuous,
unfocused_mode: UpdateMode::Continuous,
})
.add_systems(Startup, spawn)
.add_systems(Update, update_text_bounds)
.run();
Expand Down

0 comments on commit e3cf5f8

Please sign in to comment.