Skip to content

Commit

Permalink
ECS benchmarks organization (bevyengine#5189)
Browse files Browse the repository at this point in the history
## Objective

Fixes: bevyengine#5110

## Solution

- Moved benches into separate modules according to the part of ECS they are testing.
- Made so all ECS benches are included in one `benches.rs` so they don’t need to be added separately in `Cargo.toml`.
- Renamed a bunch of files to have more coherent names.
- Merged `schedule.rs` and `system_schedule.rs` into one file.
  • Loading branch information
ShadowCurse authored and ItsDoot committed Feb 1, 2023
1 parent 153ce8f commit 8fd91f0
Show file tree
Hide file tree
Showing 41 changed files with 613 additions and 640 deletions.
34 changes: 2 additions & 32 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,8 @@ bevy_tasks = { path = "../crates/bevy_tasks" }
bevy_utils = { path = "../crates/bevy_utils" }

[[bench]]
name = "archetype_updates"
path = "benches/bevy_ecs/archetype_updates.rs"
harness = false

[[bench]]
name = "ecs_bench_suite"
path = "benches/bevy_ecs/ecs_bench_suite/mod.rs"
harness = false

[[bench]]
name = "run_criteria"
path = "benches/bevy_ecs/run_criteria.rs"
harness = false

[[bench]]
name = "commands"
path = "benches/bevy_ecs/commands.rs"
harness = false

[[bench]]
name = "system_stage"
path = "benches/bevy_ecs/stages.rs"
harness = false

[[bench]]
name = "world_get"
path = "benches/bevy_ecs/world_get.rs"
harness = false

[[bench]]
name = "schedule"
path = "benches/bevy_ecs/schedule.rs"
name = "ecs"
path = "benches/bevy_ecs/benches.rs"
harness = false

[[bench]]
Expand Down
13 changes: 13 additions & 0 deletions benches/benches/bevy_ecs/benches.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use criterion::criterion_main;

mod components;
mod iteration;
mod scheduling;
mod world;

criterion_main!(
iteration::iterations_benches,
components::components_benches,
scheduling::scheduling_benches,
world::world_benches,
);
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ use bevy_ecs::{
schedule::{Stage, SystemStage},
world::World,
};
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};

criterion_group!(benches, no_archetypes, added_archetypes);
criterion_main!(benches);
use criterion::{BenchmarkId, Criterion};

#[derive(Component)]
struct A<const N: u16>(f32);
Expand Down Expand Up @@ -77,7 +74,7 @@ fn add_archetypes(world: &mut World, count: u16) {
}
}

fn no_archetypes(criterion: &mut Criterion) {
pub fn no_archetypes(criterion: &mut Criterion) {
let mut group = criterion.benchmark_group("no_archetypes");
for i in 0..=5 {
let system_count = i * 20;
Expand All @@ -94,7 +91,7 @@ fn no_archetypes(criterion: &mut Criterion) {
}
}

fn added_archetypes(criterion: &mut Criterion) {
pub fn added_archetypes(criterion: &mut Criterion) {
const SYSTEM_COUNT: usize = 100;
let mut group = criterion.benchmark_group("added_archetypes");
for archetype_count in [100, 200, 500, 1000, 2000, 5000, 10000] {
Expand Down
65 changes: 65 additions & 0 deletions benches/benches/bevy_ecs/components/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
use criterion::*;

mod add_remove_big_sparse_set;
mod add_remove_big_table;
mod add_remove_sparse_set;
mod add_remove_table;
mod archetype_updates;
mod insert_simple;
mod insert_simple_unbatched;

use archetype_updates::*;

criterion_group!(
components_benches,
add_remove,
add_remove_big,
insert_simple,
no_archetypes,
added_archetypes,
);

fn add_remove(c: &mut Criterion) {
let mut group = c.benchmark_group("add_remove");
group.warm_up_time(std::time::Duration::from_millis(500));
group.measurement_time(std::time::Duration::from_secs(4));
group.bench_function("table", |b| {
let mut bench = add_remove_table::Benchmark::new();
b.iter(move || bench.run());
});
group.bench_function("sparse_set", |b| {
let mut bench = add_remove_sparse_set::Benchmark::new();
b.iter(move || bench.run());
});
group.finish();
}

fn add_remove_big(c: &mut Criterion) {
let mut group = c.benchmark_group("add_remove_big");
group.warm_up_time(std::time::Duration::from_millis(500));
group.measurement_time(std::time::Duration::from_secs(4));
group.bench_function("table", |b| {
let mut bench = add_remove_big_table::Benchmark::new();
b.iter(move || bench.run());
});
group.bench_function("sparse_set", |b| {
let mut bench = add_remove_big_sparse_set::Benchmark::new();
b.iter(move || bench.run());
});
group.finish();
}

fn insert_simple(c: &mut Criterion) {
let mut group = c.benchmark_group("insert_simple");
group.warm_up_time(std::time::Duration::from_millis(500));
group.measurement_time(std::time::Duration::from_secs(4));
group.bench_function("base", |b| {
let mut bench = insert_simple::Benchmark::new();
b.iter(move || bench.run());
});
group.bench_function("unbatched", |b| {
let mut bench = insert_simple_unbatched::Benchmark::new();
b.iter(move || bench.run());
});
group.finish();
}
23 changes: 0 additions & 23 deletions benches/benches/bevy_ecs/ecs_bench_suite/get_component.rs

This file was deleted.

29 changes: 0 additions & 29 deletions benches/benches/bevy_ecs/ecs_bench_suite/get_component_system.rs

This file was deleted.

Loading

0 comments on commit 8fd91f0

Please sign in to comment.