-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add bevymark benchmark example #273
Conversation
This is cool! Can we add the FPS to the screen as well? I think that should be pretty straight forward. |
I agree that FPS as UI would be helpful here. Edit: it would probably be nice to have something even more fine grained, akin to RTSS's per-cpu-core-usage stats. That is probably out of scope though. |
Yup this will be a nice way to measure progress on performance. I'm sold! |
Had a bit of a busy weekend, will look into adding the FPS counter on screen updates over the next few days. |
@cart, added the FPS display as requested |
examples/tools/bevymark.rs
Outdated
.run(); | ||
} | ||
|
||
fn setup( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can clean up this optional resource a little bit like this:
struct BirdMaterial(Handle<ColorMaterial>);
fn setup(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut materials: ResMut<Assets<ColorMaterial>>,
) {
commands.insert_resource(BirdMaterial(
materials.add(
asset_server
.load("assets/branding/icon.png")
.unwrap()
.into(),
),
));
examples/tools/bevymark.rs
Outdated
let new_y = bird.velocity.y() + GRAVITY; | ||
bird.velocity.set_y(new_y); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes gravity acceleration framerate dependent. We can correct this (and make it a bit terser) like this:
*bird.velocity.y_mut() += GRAVITY * time.delta_seconds;
This correction exposes something interesting: the scale is quite "off". You'll notice the birds appear to accelerate very slowly. This is because each pixel is currently a "meter", so the window is 800 "meters" tall.
We can fix this by just cranking up the gravity:
const GRAVITY: f32 = -9.8 * 100.0; // multiply by 100 to account for scale
} | ||
} | ||
|
||
fn counter_system( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty good case for a "for-each system":
fn counter_system(diagnostics: Res<Diagnostics>, counter: Res<BevyCounter>, mut text: Mut<Text>) {
if let Some(fps) = diagnostics.get(FrameTimeDiagnosticsPlugin::FPS) {
if let Some(average) = fps.average() {
text.value = format!("Bird Count: {}\nAverage FPS: {:.2}", counter.count, average);
}
};
}
Leaving this here in case it helps. I used the changes that @cart suggested and updated the API to use v0.3
This are my stats with a MacBook Pro i9 2.3GHz - 32GB Ram - Intel UHD Graphics 630 1536MB:
|
Alrighty I updated it with the changes from @Nazariglez, as well as a few more changes to adapt to the latest master branch. |
@RobDavenport @Nazariglez we need your permissions in #2373 to keep this example in the repository. Please read that and comment at your earliest convenience. Thanks! |
Done: #2373 (comment) Thanks |
Added a "bunnymark" example we can all use for testing performance as the engine progresses. Wasn't sure where to put this, so I just made a new folder called "Tools." Perhaps we can put future 3d benchmarks in there as well?
Run the example with `cargo run --release --example bevymark
Click in the screens pace to spawn some sprites.
Check the for FPS output.