Skip to content
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

Enhance bevymark #9674

Merged
merged 3 commits into from
Sep 2, 2023
Merged

Enhance bevymark #9674

merged 3 commits into from
Sep 2, 2023

Conversation

superdump
Copy link
Contributor

@superdump superdump commented Sep 2, 2023

Objective

  • In preparation for an initial 2D/3D mesh batching/instancing PR, enhance bevymark to support some different test modes that enable comparison and optimisation of performance

Solution

  • Use argh for command line interface options
  • Use seeded StdRng for reproducible random number generation
  • Add a mode for testing 2D meshes that includes an option to uniquely vary the data of each material by setting a random flat colour on the ColorMaterial.
  • Add a way of specifying the number of different textures to use for sprites or meshes. These are generated at the same resolution as the Bevy bird icon, but are just random flat colours for testing.
  • Add a benchmark mode that spawns all entities during setup, and animates the entities using a fixed delta time for reproducible animation. The initially-spawned entities are still spawned in waves and animated as they would have been had they spawned at intervals.

@superdump superdump force-pushed the bevymark-enhanced branch 2 times, most recently from f80b966 to e2aa8a3 Compare September 2, 2023 17:04
@superdump superdump force-pushed the bevymark-enhanced branch 4 times, most recently from 7d6cb3d to 96f5926 Compare September 2, 2023 17:56
@IceSentry
Copy link
Contributor

IceSentry commented Sep 2, 2023

When spawning the text I'd suggest using this instead:

    commands
        .spawn(NodeBundle {
            style: Style {
                position_type: PositionType::Absolute,
                padding: UiRect::all(Val::Px(5.0)),
                ..default()
            },
            z_index: ZIndex::Global(i32::MAX),
            background_color: Color::BLACK.with_a(0.75).into(),
            ..default()
        })
        .with_children(|c| {
            c.spawn((
                TextBundle::from_sections([
                    text_section(Color::GREEN, "Bird Count"),
                    text_section(Color::CYAN, ""),
                    text_section(Color::GREEN, "\nFPS (raw): "),
                    text_section(Color::CYAN, ""),
                    text_section(Color::GREEN, "\nFPS (SMA): "),
                    text_section(Color::CYAN, ""),
                    text_section(Color::GREEN, "\nFPS (EMA): "),
                    text_section(Color::CYAN, ""),
                ]),
                StatsText,
            ));
        });

It will add a dark background to the text and makes it much easier to read

image

Your PR didn't touch that part so I can't add it as a code suggestion in my review.

- Use `argh` for command line interface options
- Use seeded StdRng for reproducible random number generation
- Add a mode for testing 2D meshes that includes an option to uniquely vary the
  data of each material by setting a random flat colour on the ColorMaterial.
- Add a way of specifying the number of different textures to use for sprites
  or meshes. These are generated at the same resolution as the Bevy bird icon,
  but are just random flat colours for testing.
- Add a benchmark mode that spawns all entities during setup, and animates the
  entities using a fixed delta time for reproducible animation. The
  initially-spawned entities are still spawned in waves and animated as they
  would have been had they spawned at intervals.
Copy link
Contributor

@IceSentry IceSentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I get why using --benchmark spawns all waves at once instead of on a timer. Seems to me it could be useful to detect spawning overhead if we don't spawn everything at once? Maybe it could be a separate flag?

Other than that LGTM

examples/stress_tests/bevymark.rs Outdated Show resolved Hide resolved
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems sensible enough :) IceSentry's comments are good, but I'll leave it to you how much you want to do here.

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples C-Performance A change motivated by improving speed, memory usage or compile times S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Sep 2, 2023
@superdump
Copy link
Contributor Author

The reason to spawn everything up-front is to immediately get to the heavy rendering load. bevymark is in my opinion a 2D rendering stress test and not an ECS spawning stress test. So I think it’s useful to capture more profile data at max load.

@superdump superdump added this pull request to the merge queue Sep 2, 2023
Merged via the queue into bevyengine:main with commit e9b3aeb Sep 2, 2023
21 checks passed
@cart cart mentioned this pull request Oct 13, 2023
43 tasks
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

- In preparation for an initial 2D/3D mesh batching/instancing PR,
enhance `bevymark` to support some different test modes that enable
comparison and optimisation of performance
 
## Solution

- Use `argh` for command line interface options
- Use seeded `StdRng` for reproducible random number generation
- Add a mode for testing 2D meshes that includes an option to uniquely
vary the data of each material by setting a random flat colour on the
`ColorMaterial`.
- Add a way of specifying the number of different textures to use for
sprites or meshes. These are generated at the same resolution as the
Bevy bird icon, but are just random flat colours for testing.
- Add a benchmark mode that spawns all entities during setup, and
animates the entities using a fixed delta time for reproducible
animation. The initially-spawned entities are still spawned in waves and
animated as they would have been had they spawned at intervals.

---------

Co-authored-by: IceSentry <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples C-Performance A change motivated by improving speed, memory usage or compile times S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants