Skip to content

Commit 179f719

Browse files
committed
ECS benchmarks organization (#5189)
## Objective Fixes: #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.
1 parent 050251d commit 179f719

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+613
-640
lines changed

benches/Cargo.toml

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,8 @@ bevy_tasks = { path = "../crates/bevy_tasks" }
1818
bevy_utils = { path = "../crates/bevy_utils" }
1919

2020
[[bench]]
21-
name = "archetype_updates"
22-
path = "benches/bevy_ecs/archetype_updates.rs"
23-
harness = false
24-
25-
[[bench]]
26-
name = "ecs_bench_suite"
27-
path = "benches/bevy_ecs/ecs_bench_suite/mod.rs"
28-
harness = false
29-
30-
[[bench]]
31-
name = "run_criteria"
32-
path = "benches/bevy_ecs/run_criteria.rs"
33-
harness = false
34-
35-
[[bench]]
36-
name = "commands"
37-
path = "benches/bevy_ecs/commands.rs"
38-
harness = false
39-
40-
[[bench]]
41-
name = "system_stage"
42-
path = "benches/bevy_ecs/stages.rs"
43-
harness = false
44-
45-
[[bench]]
46-
name = "world_get"
47-
path = "benches/bevy_ecs/world_get.rs"
48-
harness = false
49-
50-
[[bench]]
51-
name = "schedule"
52-
path = "benches/bevy_ecs/schedule.rs"
21+
name = "ecs"
22+
path = "benches/bevy_ecs/benches.rs"
5323
harness = false
5424

5525
[[bench]]

benches/benches/bevy_ecs/benches.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use criterion::criterion_main;
2+
3+
mod components;
4+
mod iteration;
5+
mod scheduling;
6+
mod world;
7+
8+
criterion_main!(
9+
iteration::iterations_benches,
10+
components::components_benches,
11+
scheduling::scheduling_benches,
12+
world::world_benches,
13+
);

benches/benches/bevy_ecs/archetype_updates.rs renamed to benches/benches/bevy_ecs/components/archetype_updates.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ use bevy_ecs::{
33
schedule::{Stage, SystemStage},
44
world::World,
55
};
6-
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
7-
8-
criterion_group!(benches, no_archetypes, added_archetypes);
9-
criterion_main!(benches);
6+
use criterion::{BenchmarkId, Criterion};
107

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

80-
fn no_archetypes(criterion: &mut Criterion) {
77+
pub fn no_archetypes(criterion: &mut Criterion) {
8178
let mut group = criterion.benchmark_group("no_archetypes");
8279
for i in 0..=5 {
8380
let system_count = i * 20;
@@ -94,7 +91,7 @@ fn no_archetypes(criterion: &mut Criterion) {
9491
}
9592
}
9693

97-
fn added_archetypes(criterion: &mut Criterion) {
94+
pub fn added_archetypes(criterion: &mut Criterion) {
9895
const SYSTEM_COUNT: usize = 100;
9996
let mut group = criterion.benchmark_group("added_archetypes");
10097
for archetype_count in [100, 200, 500, 1000, 2000, 5000, 10000] {
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
use criterion::*;
2+
3+
mod add_remove_big_sparse_set;
4+
mod add_remove_big_table;
5+
mod add_remove_sparse_set;
6+
mod add_remove_table;
7+
mod archetype_updates;
8+
mod insert_simple;
9+
mod insert_simple_unbatched;
10+
11+
use archetype_updates::*;
12+
13+
criterion_group!(
14+
components_benches,
15+
add_remove,
16+
add_remove_big,
17+
insert_simple,
18+
no_archetypes,
19+
added_archetypes,
20+
);
21+
22+
fn add_remove(c: &mut Criterion) {
23+
let mut group = c.benchmark_group("add_remove");
24+
group.warm_up_time(std::time::Duration::from_millis(500));
25+
group.measurement_time(std::time::Duration::from_secs(4));
26+
group.bench_function("table", |b| {
27+
let mut bench = add_remove_table::Benchmark::new();
28+
b.iter(move || bench.run());
29+
});
30+
group.bench_function("sparse_set", |b| {
31+
let mut bench = add_remove_sparse_set::Benchmark::new();
32+
b.iter(move || bench.run());
33+
});
34+
group.finish();
35+
}
36+
37+
fn add_remove_big(c: &mut Criterion) {
38+
let mut group = c.benchmark_group("add_remove_big");
39+
group.warm_up_time(std::time::Duration::from_millis(500));
40+
group.measurement_time(std::time::Duration::from_secs(4));
41+
group.bench_function("table", |b| {
42+
let mut bench = add_remove_big_table::Benchmark::new();
43+
b.iter(move || bench.run());
44+
});
45+
group.bench_function("sparse_set", |b| {
46+
let mut bench = add_remove_big_sparse_set::Benchmark::new();
47+
b.iter(move || bench.run());
48+
});
49+
group.finish();
50+
}
51+
52+
fn insert_simple(c: &mut Criterion) {
53+
let mut group = c.benchmark_group("insert_simple");
54+
group.warm_up_time(std::time::Duration::from_millis(500));
55+
group.measurement_time(std::time::Duration::from_secs(4));
56+
group.bench_function("base", |b| {
57+
let mut bench = insert_simple::Benchmark::new();
58+
b.iter(move || bench.run());
59+
});
60+
group.bench_function("unbatched", |b| {
61+
let mut bench = insert_simple_unbatched::Benchmark::new();
62+
b.iter(move || bench.run());
63+
});
64+
group.finish();
65+
}

benches/benches/bevy_ecs/ecs_bench_suite/get_component.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

benches/benches/bevy_ecs/ecs_bench_suite/get_component_system.rs

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)