bevy/benches
BD103 c4a24d5b51
Make benchmark setup consistent (#16733)
# Objective

- Benchmarks are inconsistently setup, there are several that do not
compile, and several others that need to be reformatted.
- Related / precursor to #16647, this is part of my attempt migrating
[`bevy-bencher`](https://github.com/TheBevyFlock/bevy-bencher) to the
official benchmarks.

## Solution

> [!TIP]
>
> I recommend reviewing this PR commit-by-commit, instead of all at
once!

In 5d26f56eb9 I reorganized how benches
were registered. Now this is one `[[bench]]` per Bevy crate. In each
crate benchmark folder, there is a `main.rs` that calls
`criterion_main!`. I also disabled automatic benchmark discovery, which
isn't necessarily required, but may clear up confusion with our custom
setup. I also fixed a few errors that were causing the benchmarks to
fail to compile.

In afc8d33a87 I ran `rustfmt` on all of
the benchmarks.

In d6cdf960ab I fixed all of the Clippy
warnings.

In ee94d48f50 I fixed some of the
benchmarks' usage of `black_box()`. I ended up opening
https://github.com/rust-lang/rust/pull/133942 due to this, which should
help prevent this in the future.

In cbe1688dcd I renamed all of the ECS
benchmark groups to be called `benches`, to be consistent with the other
crate benchmarks.

In e701c212cd and
8815bb78b0 I re-ordered some imports and
module definitions, and uplifted `fragmentation/mod.rs` to
`fragementation.rs`.

Finally, in b0065e0b0b I organized
`Cargo.toml` and bumped Criterion to v0.5.

## Testing

- `cd benches && cargo clippy --benches`
- `cd benches && cargo fmt --all`
2024-12-10 20:39:14 +00:00
..
benches Make benchmark setup consistent (#16733) 2024-12-10 20:39:14 +00:00
Cargo.toml Make benchmark setup consistent (#16733) 2024-12-10 20:39:14 +00:00
README.md Add README to benches (#11508) 2024-01-24 17:11:28 +00:00

Bevy Benchmarks

This is a crate with a collection of benchmarks for Bevy, separate from the rest of the Bevy crates.

Running the benchmarks

  1. Setup everything you need for Bevy with the setup guide.

  2. Move into the benches directory (where this README is located).

    bevy $ cd benches
    
  3. Run the benchmarks with cargo (This will take a while)

    bevy/benches $ cargo bench
    

    If you'd like to only compile the benchmarks (without running them), you can do that like this:

    bevy/benches $ cargo bench --no-run
    

Criterion

Bevy's benchmarks use Criterion. If you want to learn more about using Criterion for comparing performance against a baseline or generating detailed reports, you can read the Criterion.rs documentation.