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! In5d26f56eb9
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. Inafc8d33a87
I ran `rustfmt` on all of the benchmarks. Ind6cdf960ab
I fixed all of the Clippy warnings. Inee94d48f50
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. Incbe1688dcd
I renamed all of the ECS benchmark groups to be called `benches`, to be consistent with the other crate benchmarks. Ine701c212cd
and8815bb78b0
I re-ordered some imports and module definitions, and uplifted `fragmentation/mod.rs` to `fragementation.rs`. Finally, inb0065e0b0b
I organized `Cargo.toml` and bumped Criterion to v0.5. ## Testing - `cd benches && cargo clippy --benches` - `cd benches && cargo fmt --all`
This commit is contained in:
parent
c60dcea231
commit
c4a24d5b51
@ -4,12 +4,11 @@ edition = "2021"
|
|||||||
description = "Benchmarks that test Bevy's performance"
|
description = "Benchmarks that test Bevy's performance"
|
||||||
publish = false
|
publish = false
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
# Do not automatically discover benchmarks, we specify them manually instead.
|
||||||
|
autobenches = false
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
glam = "0.29"
|
# Bevy crates
|
||||||
rand = "0.8"
|
|
||||||
rand_chacha = "0.3"
|
|
||||||
criterion = { version = "0.3", features = ["html_reports"] }
|
|
||||||
bevy_app = { path = "../crates/bevy_app" }
|
bevy_app = { path = "../crates/bevy_app" }
|
||||||
bevy_ecs = { path = "../crates/bevy_ecs", features = ["multi_threaded"] }
|
bevy_ecs = { path = "../crates/bevy_ecs", features = ["multi_threaded"] }
|
||||||
bevy_hierarchy = { path = "../crates/bevy_hierarchy" }
|
bevy_hierarchy = { path = "../crates/bevy_hierarchy" }
|
||||||
@ -22,7 +21,14 @@ bevy_render = { path = "../crates/bevy_render" }
|
|||||||
bevy_tasks = { path = "../crates/bevy_tasks" }
|
bevy_tasks = { path = "../crates/bevy_tasks" }
|
||||||
bevy_utils = { path = "../crates/bevy_utils" }
|
bevy_utils = { path = "../crates/bevy_utils" }
|
||||||
|
|
||||||
# make bevy_render compile on linux. x11 vs wayland does not matter here as the benches do not actually use a window
|
# Other crates
|
||||||
|
criterion = { version = "0.5.1", features = ["html_reports"] }
|
||||||
|
glam = "0.29"
|
||||||
|
rand = "0.8"
|
||||||
|
rand_chacha = "0.3"
|
||||||
|
|
||||||
|
# Make `bevy_render` compile on Linux with x11 windowing. x11 vs. Wayland does not matter here
|
||||||
|
# because the benches do not actually open any windows.
|
||||||
[target.'cfg(target_os = "linux")'.dev-dependencies]
|
[target.'cfg(target_os = "linux")'.dev-dependencies]
|
||||||
bevy_winit = { path = "../crates/bevy_winit", features = ["x11"] }
|
bevy_winit = { path = "../crates/bevy_winit", features = ["x11"] }
|
||||||
|
|
||||||
@ -30,62 +36,32 @@ bevy_winit = { path = "../crates/bevy_winit", features = ["x11"] }
|
|||||||
opt-level = 3
|
opt-level = 3
|
||||||
lto = true
|
lto = true
|
||||||
|
|
||||||
[[bench]]
|
|
||||||
name = "change_detection"
|
|
||||||
path = "benches/bevy_ecs/change_detection.rs"
|
|
||||||
harness = false
|
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "ecs"
|
name = "ecs"
|
||||||
path = "benches/bevy_ecs/benches.rs"
|
path = "benches/bevy_ecs/main.rs"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "ray_mesh_intersection"
|
name = "math"
|
||||||
path = "benches/bevy_picking/ray_mesh_intersection.rs"
|
path = "benches/bevy_math/main.rs"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "reflect_function"
|
name = "picking"
|
||||||
path = "benches/bevy_reflect/function.rs"
|
path = "benches/bevy_picking/main.rs"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "reflect_list"
|
name = "reflect"
|
||||||
path = "benches/bevy_reflect/list.rs"
|
path = "benches/bevy_reflect/main.rs"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "reflect_map"
|
name = "render"
|
||||||
path = "benches/bevy_reflect/map.rs"
|
path = "benches/bevy_render/main.rs"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "reflect_struct"
|
name = "tasks"
|
||||||
path = "benches/bevy_reflect/struct.rs"
|
path = "benches/bevy_tasks/main.rs"
|
||||||
harness = false
|
|
||||||
|
|
||||||
[[bench]]
|
|
||||||
name = "parse_reflect_path"
|
|
||||||
path = "benches/bevy_reflect/path.rs"
|
|
||||||
harness = false
|
|
||||||
|
|
||||||
[[bench]]
|
|
||||||
name = "iter"
|
|
||||||
path = "benches/bevy_tasks/iter.rs"
|
|
||||||
harness = false
|
|
||||||
|
|
||||||
[[bench]]
|
|
||||||
name = "bezier"
|
|
||||||
path = "benches/bevy_math/bezier.rs"
|
|
||||||
harness = false
|
|
||||||
|
|
||||||
[[bench]]
|
|
||||||
name = "torus"
|
|
||||||
path = "benches/bevy_render/torus.rs"
|
|
||||||
harness = false
|
|
||||||
|
|
||||||
[[bench]]
|
|
||||||
name = "entity_hash"
|
|
||||||
path = "benches/bevy_ecs/world/entity_hash.rs"
|
|
||||||
harness = false
|
harness = false
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
#![expect(dead_code, reason = "Many fields are unused/unread as they are just for benchmarking purposes.")]
|
|
||||||
|
|
||||||
use criterion::criterion_main;
|
|
||||||
|
|
||||||
mod components;
|
|
||||||
mod events;
|
|
||||||
mod fragmentation;
|
|
||||||
mod iteration;
|
|
||||||
mod observers;
|
|
||||||
mod param;
|
|
||||||
mod scheduling;
|
|
||||||
mod world;
|
|
||||||
|
|
||||||
criterion_main!(
|
|
||||||
components::components_benches,
|
|
||||||
events::event_benches,
|
|
||||||
iteration::iterations_benches,
|
|
||||||
fragmentation::fragmentation_benches,
|
|
||||||
observers::observer_benches,
|
|
||||||
scheduling::scheduling_benches,
|
|
||||||
world::world_benches,
|
|
||||||
param::param_benches,
|
|
||||||
);
|
|
@ -5,7 +5,7 @@ use bevy_ecs::{
|
|||||||
query::QueryFilter,
|
query::QueryFilter,
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, Criterion};
|
||||||
use rand::{prelude::SliceRandom, SeedableRng};
|
use rand::{prelude::SliceRandom, SeedableRng};
|
||||||
use rand_chacha::ChaCha8Rng;
|
use rand_chacha::ChaCha8Rng;
|
||||||
|
|
||||||
@ -17,7 +17,6 @@ criterion_group!(
|
|||||||
none_changed_detection,
|
none_changed_detection,
|
||||||
multiple_archetype_none_changed_detection
|
multiple_archetype_none_changed_detection
|
||||||
);
|
);
|
||||||
criterion_main!(benches);
|
|
||||||
|
|
||||||
macro_rules! modify {
|
macro_rules! modify {
|
||||||
($components:ident;$($index:tt),*) => {
|
($components:ident;$($index:tt),*) => {
|
||||||
@ -96,7 +95,7 @@ fn all_added_detection_generic<T: Component + Default>(group: &mut BenchGroup, e
|
|||||||
},
|
},
|
||||||
|(ref mut world, ref mut query)| {
|
|(ref mut world, ref mut query)| {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
for entity in query.iter(&world) {
|
for entity in query.iter(world) {
|
||||||
black_box(entity);
|
black_box(entity);
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
@ -144,7 +143,7 @@ fn all_changed_detection_generic<T: Component<Mutability = Mutable> + Default +
|
|||||||
},
|
},
|
||||||
|(ref mut world, ref mut query)| {
|
|(ref mut world, ref mut query)| {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
for entity in query.iter(&world) {
|
for entity in query.iter(world) {
|
||||||
black_box(entity);
|
black_box(entity);
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
@ -196,7 +195,7 @@ fn few_changed_detection_generic<T: Component<Mutability = Mutable> + Default +
|
|||||||
(world, query)
|
(world, query)
|
||||||
},
|
},
|
||||||
|(ref mut world, ref mut query)| {
|
|(ref mut world, ref mut query)| {
|
||||||
for entity in query.iter(&world) {
|
for entity in query.iter(world) {
|
||||||
black_box(entity);
|
black_box(entity);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -238,7 +237,7 @@ fn none_changed_detection_generic<T: Component<Mutability = Mutable> + Default>(
|
|||||||
},
|
},
|
||||||
|(ref mut world, ref mut query)| {
|
|(ref mut world, ref mut query)| {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
for entity in query.iter(&world) {
|
for entity in query.iter(world) {
|
||||||
black_box(entity);
|
black_box(entity);
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
@ -298,7 +297,9 @@ fn add_archetypes_entities<T: Component<Mutability = Mutable> + Default>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn multiple_archetype_none_changed_detection_generic<T: Component<Mutability = Mutable> + Default + BenchModify>(
|
fn multiple_archetype_none_changed_detection_generic<
|
||||||
|
T: Component<Mutability = Mutable> + Default + BenchModify,
|
||||||
|
>(
|
||||||
group: &mut BenchGroup,
|
group: &mut BenchGroup,
|
||||||
archetype_count: u16,
|
archetype_count: u16,
|
||||||
entity_count: u32,
|
entity_count: u32,
|
||||||
@ -342,7 +343,7 @@ fn multiple_archetype_none_changed_detection_generic<T: Component<Mutability = M
|
|||||||
},
|
},
|
||||||
|(ref mut world, ref mut query)| {
|
|(ref mut world, ref mut query)| {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
for entity in query.iter(&world) {
|
for entity in query.iter(world) {
|
||||||
black_box(entity);
|
black_box(entity);
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,18 @@
|
|||||||
use criterion::*;
|
mod add_remove;
|
||||||
|
|
||||||
mod add_remove_big_sparse_set;
|
mod add_remove_big_sparse_set;
|
||||||
mod add_remove_big_table;
|
mod add_remove_big_table;
|
||||||
mod add_remove_sparse_set;
|
mod add_remove_sparse_set;
|
||||||
mod add_remove_table;
|
mod add_remove_table;
|
||||||
mod add_remove_very_big_table;
|
mod add_remove_very_big_table;
|
||||||
mod add_remove;
|
|
||||||
mod archetype_updates;
|
mod archetype_updates;
|
||||||
mod insert_simple;
|
mod insert_simple;
|
||||||
mod insert_simple_unbatched;
|
mod insert_simple_unbatched;
|
||||||
|
|
||||||
use archetype_updates::*;
|
use archetype_updates::*;
|
||||||
|
use criterion::{criterion_group, Criterion};
|
||||||
|
|
||||||
criterion_group!(
|
criterion_group!(
|
||||||
components_benches,
|
benches,
|
||||||
add_remove,
|
add_remove,
|
||||||
add_remove_big,
|
add_remove_big,
|
||||||
add_remove_very_big,
|
add_remove_very_big,
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
use bevy_ecs::{component::Component, prelude::*, world::World};
|
use bevy_ecs::{component::Component, prelude::*, schedule::ExecutorKind, world::World};
|
||||||
use bevy_tasks::{ComputeTaskPool, TaskPool};
|
use criterion::{black_box, criterion_group, BenchmarkId, Criterion};
|
||||||
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
|
|
||||||
|
|
||||||
criterion_group!(benches, empty_archetypes);
|
criterion_group!(benches, empty_archetypes);
|
||||||
criterion_main!(benches);
|
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct A<const N: u16>(f32);
|
struct A<const N: u16>(f32);
|
||||||
@ -47,13 +45,12 @@ fn for_each(
|
|||||||
&A<12>,
|
&A<12>,
|
||||||
)>,
|
)>,
|
||||||
) {
|
) {
|
||||||
query.for_each(|comp| {
|
query.iter().for_each(|comp| {
|
||||||
black_box(comp);
|
black_box(comp);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn par_for_each(
|
fn par_for_each(
|
||||||
task_pool: Res<ComputeTaskPool>,
|
|
||||||
query: Query<(
|
query: Query<(
|
||||||
&A<0>,
|
&A<0>,
|
||||||
&A<1>,
|
&A<1>,
|
||||||
@ -70,25 +67,29 @@ fn par_for_each(
|
|||||||
&A<12>,
|
&A<12>,
|
||||||
)>,
|
)>,
|
||||||
) {
|
) {
|
||||||
query.par_for_each(&*task_pool, 64, |comp| {
|
query.par_iter().for_each(|comp| {
|
||||||
black_box(comp);
|
black_box(comp);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(parallel: bool, setup: impl FnOnce(&mut Schedule)) -> (World, Schedule) {
|
fn setup(parallel: bool, setup: impl FnOnce(&mut Schedule)) -> (World, Schedule) {
|
||||||
let mut world = World::new();
|
let world = World::new();
|
||||||
let mut schedule = Schedule::default();
|
let mut schedule = Schedule::default();
|
||||||
if parallel {
|
|
||||||
world.insert_resource(ComputeTaskPool(TaskPool::default()));
|
schedule.set_executor_kind(match parallel {
|
||||||
}
|
true => ExecutorKind::MultiThreaded,
|
||||||
|
false => ExecutorKind::SingleThreaded,
|
||||||
|
});
|
||||||
|
|
||||||
setup(&mut schedule);
|
setup(&mut schedule);
|
||||||
|
|
||||||
(world, schedule)
|
(world, schedule)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// create `count` entities with distinct archetypes
|
/// create `count` entities with distinct archetypes
|
||||||
fn add_archetypes(world: &mut World, count: u16) {
|
fn add_archetypes(world: &mut World, count: u16) {
|
||||||
for i in 0..count {
|
for i in 0..count {
|
||||||
let mut e = world.spawn();
|
let mut e = world.spawn_empty();
|
||||||
e.insert(A::<0>(1.0));
|
e.insert(A::<0>(1.0));
|
||||||
e.insert(A::<1>(1.0));
|
e.insert(A::<1>(1.0));
|
||||||
e.insert(A::<2>(1.0));
|
e.insert(A::<2>(1.0));
|
||||||
@ -158,7 +159,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
|
|||||||
});
|
});
|
||||||
add_archetypes(&mut world, archetype_count);
|
add_archetypes(&mut world, archetype_count);
|
||||||
world.clear_entities();
|
world.clear_entities();
|
||||||
let mut e = world.spawn();
|
let mut e = world.spawn_empty();
|
||||||
e.insert(A::<0>(1.0));
|
e.insert(A::<0>(1.0));
|
||||||
e.insert(A::<1>(1.0));
|
e.insert(A::<1>(1.0));
|
||||||
e.insert(A::<2>(1.0));
|
e.insert(A::<2>(1.0));
|
||||||
@ -189,7 +190,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
|
|||||||
});
|
});
|
||||||
add_archetypes(&mut world, archetype_count);
|
add_archetypes(&mut world, archetype_count);
|
||||||
world.clear_entities();
|
world.clear_entities();
|
||||||
let mut e = world.spawn();
|
let mut e = world.spawn_empty();
|
||||||
e.insert(A::<0>(1.0));
|
e.insert(A::<0>(1.0));
|
||||||
e.insert(A::<1>(1.0));
|
e.insert(A::<1>(1.0));
|
||||||
e.insert(A::<2>(1.0));
|
e.insert(A::<2>(1.0));
|
||||||
@ -220,7 +221,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
|
|||||||
});
|
});
|
||||||
add_archetypes(&mut world, archetype_count);
|
add_archetypes(&mut world, archetype_count);
|
||||||
world.clear_entities();
|
world.clear_entities();
|
||||||
let mut e = world.spawn();
|
let mut e = world.spawn_empty();
|
||||||
e.insert(A::<0>(1.0));
|
e.insert(A::<0>(1.0));
|
||||||
e.insert(A::<1>(1.0));
|
e.insert(A::<1>(1.0));
|
||||||
e.insert(A::<2>(1.0));
|
e.insert(A::<2>(1.0));
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use criterion::*;
|
|
||||||
|
|
||||||
mod iter;
|
mod iter;
|
||||||
mod send;
|
mod send;
|
||||||
|
|
||||||
criterion_group!(event_benches, send, iter);
|
use criterion::{criterion_group, Criterion};
|
||||||
|
|
||||||
|
criterion_group!(benches, send, iter);
|
||||||
|
|
||||||
fn send(c: &mut Criterion) {
|
fn send(c: &mut Criterion) {
|
||||||
let mut group = c.benchmark_group("events_send");
|
let mut group = c.benchmark_group("events_send");
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy_ecs::system::SystemState;
|
use bevy_ecs::system::SystemState;
|
||||||
|
use core::hint::black_box;
|
||||||
use criterion::*;
|
use criterion::*;
|
||||||
use glam::*;
|
use glam::*;
|
||||||
use core::hint::black_box;
|
|
||||||
|
|
||||||
criterion_group!(fragmentation_benches, iter_frag_empty);
|
criterion_group!(benches, iter_frag_empty);
|
||||||
|
|
||||||
#[derive(Component, Default)]
|
#[derive(Component, Default)]
|
||||||
struct Table<const X: usize = 0>(usize);
|
struct Table<const X: usize = 0>(usize);
|
@ -1,5 +1,3 @@
|
|||||||
use criterion::*;
|
|
||||||
|
|
||||||
mod heavy_compute;
|
mod heavy_compute;
|
||||||
mod iter_frag;
|
mod iter_frag;
|
||||||
mod iter_frag_foreach;
|
mod iter_frag_foreach;
|
||||||
@ -22,10 +20,11 @@ mod iter_simple_wide_sparse_set;
|
|||||||
mod par_iter_simple;
|
mod par_iter_simple;
|
||||||
mod par_iter_simple_foreach_hybrid;
|
mod par_iter_simple_foreach_hybrid;
|
||||||
|
|
||||||
|
use criterion::{criterion_group, Criterion};
|
||||||
use heavy_compute::*;
|
use heavy_compute::*;
|
||||||
|
|
||||||
criterion_group!(
|
criterion_group!(
|
||||||
iterations_benches,
|
benches,
|
||||||
iter_frag,
|
iter_frag,
|
||||||
iter_frag_sparse,
|
iter_frag_sparse,
|
||||||
iter_simple,
|
iter_simple,
|
||||||
@ -136,7 +135,7 @@ fn par_iter_simple(c: &mut Criterion) {
|
|||||||
b.iter(move || bench.run());
|
b.iter(move || bench.run());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
group.bench_function(format!("hybrid"), |b| {
|
group.bench_function("hybrid".to_string(), |b| {
|
||||||
let mut bench = par_iter_simple_foreach_hybrid::Benchmark::new();
|
let mut bench = par_iter_simple_foreach_hybrid::Benchmark::new();
|
||||||
b.iter(move || bench.run());
|
b.iter(move || bench.run());
|
||||||
});
|
});
|
||||||
|
31
benches/benches/bevy_ecs/main.rs
Normal file
31
benches/benches/bevy_ecs/main.rs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#![expect(
|
||||||
|
dead_code,
|
||||||
|
reason = "Many fields are unused/unread as they are just for benchmarking purposes."
|
||||||
|
)]
|
||||||
|
#![expect(clippy::type_complexity)]
|
||||||
|
|
||||||
|
use criterion::criterion_main;
|
||||||
|
|
||||||
|
mod change_detection;
|
||||||
|
mod components;
|
||||||
|
mod empty_archetypes;
|
||||||
|
mod events;
|
||||||
|
mod fragmentation;
|
||||||
|
mod iteration;
|
||||||
|
mod observers;
|
||||||
|
mod param;
|
||||||
|
mod scheduling;
|
||||||
|
mod world;
|
||||||
|
|
||||||
|
criterion_main!(
|
||||||
|
change_detection::benches,
|
||||||
|
components::benches,
|
||||||
|
empty_archetypes::benches,
|
||||||
|
events::benches,
|
||||||
|
iteration::benches,
|
||||||
|
fragmentation::benches,
|
||||||
|
observers::benches,
|
||||||
|
scheduling::benches,
|
||||||
|
world::benches,
|
||||||
|
param::benches,
|
||||||
|
);
|
@ -1,8 +1,8 @@
|
|||||||
use criterion::criterion_group;
|
|
||||||
|
|
||||||
mod propagation;
|
mod propagation;
|
||||||
mod simple;
|
mod simple;
|
||||||
|
|
||||||
|
use criterion::criterion_group;
|
||||||
use propagation::*;
|
use propagation::*;
|
||||||
use simple::*;
|
use simple::*;
|
||||||
|
|
||||||
criterion_group!(observer_benches, event_propagation, observe_simple);
|
criterion_group!(benches, event_propagation, observe_simple);
|
||||||
|
@ -71,7 +71,7 @@ impl<const N: usize> Event for TestEvent<N> {
|
|||||||
const AUTO_PROPAGATE: bool = true;
|
const AUTO_PROPAGATE: bool = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_events<const N: usize, const N_EVENTS: usize>(world: &mut World, leaves: &Vec<Entity>) {
|
fn send_events<const N: usize, const N_EVENTS: usize>(world: &mut World, leaves: &[Entity]) {
|
||||||
let target = leaves.iter().choose(&mut rand::thread_rng()).unwrap();
|
let target = leaves.iter().choose(&mut rand::thread_rng()).unwrap();
|
||||||
|
|
||||||
(0..N_EVENTS).for_each(|_| {
|
(0..N_EVENTS).for_each(|_| {
|
||||||
@ -100,9 +100,9 @@ fn spawn_listener_hierarchy(world: &mut World) -> (Vec<Entity>, Vec<Entity>, Vec
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn add_listeners_to_hierarchy<const DENSITY: usize, const N: usize>(
|
fn add_listeners_to_hierarchy<const DENSITY: usize, const N: usize>(
|
||||||
roots: &Vec<Entity>,
|
roots: &[Entity],
|
||||||
leaves: &Vec<Entity>,
|
leaves: &[Entity],
|
||||||
nodes: &Vec<Entity>,
|
nodes: &[Entity],
|
||||||
world: &mut World,
|
world: &mut World,
|
||||||
) {
|
) {
|
||||||
for e in roots.iter() {
|
for e in roots.iter() {
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
use criterion::criterion_group;
|
|
||||||
|
|
||||||
mod combinator_system;
|
mod combinator_system;
|
||||||
mod dyn_param;
|
mod dyn_param;
|
||||||
mod param_set;
|
mod param_set;
|
||||||
|
|
||||||
use combinator_system::*;
|
use combinator_system::*;
|
||||||
|
use criterion::criterion_group;
|
||||||
use dyn_param::*;
|
use dyn_param::*;
|
||||||
use param_set::*;
|
use param_set::*;
|
||||||
|
|
||||||
criterion_group!(param_benches, combinator_system, dyn_param, param_set);
|
criterion_group!(benches, combinator_system, dyn_param, param_set);
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
use criterion::criterion_group;
|
|
||||||
|
|
||||||
mod run_condition;
|
mod run_condition;
|
||||||
mod running_systems;
|
mod running_systems;
|
||||||
mod schedule;
|
mod schedule;
|
||||||
|
|
||||||
|
use criterion::criterion_group;
|
||||||
use run_condition::*;
|
use run_condition::*;
|
||||||
use running_systems::*;
|
use running_systems::*;
|
||||||
use schedule::*;
|
use schedule::*;
|
||||||
|
|
||||||
criterion_group!(
|
criterion_group!(
|
||||||
scheduling_benches,
|
benches,
|
||||||
run_condition_yes,
|
run_condition_yes,
|
||||||
run_condition_no,
|
run_condition_no,
|
||||||
run_condition_yes_with_query,
|
run_condition_yes_with_query,
|
||||||
|
@ -25,7 +25,7 @@ pub fn run_condition_yes(criterion: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
// run once to initialize systems
|
// run once to initialize systems
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
group.bench_function(&format!("{:03}_systems", 5 * amount + 1), |bencher| {
|
group.bench_function(format!("{:03}_systems", 5 * amount + 1), |bencher| {
|
||||||
bencher.iter(|| {
|
bencher.iter(|| {
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
});
|
});
|
||||||
@ -48,7 +48,7 @@ pub fn run_condition_no(criterion: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
// run once to initialize systems
|
// run once to initialize systems
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
group.bench_function(&format!("{:03}_systems", 5 * amount + 1), |bencher| {
|
group.bench_function(format!("{:03}_systems", 5 * amount + 1), |bencher| {
|
||||||
bencher.iter(|| {
|
bencher.iter(|| {
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
});
|
});
|
||||||
@ -80,7 +80,7 @@ pub fn run_condition_yes_with_query(criterion: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
// run once to initialize systems
|
// run once to initialize systems
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
group.bench_function(&format!("{:03}_systems", 5 * amount + 1), |bencher| {
|
group.bench_function(format!("{:03}_systems", 5 * amount + 1), |bencher| {
|
||||||
bencher.iter(|| {
|
bencher.iter(|| {
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
});
|
});
|
||||||
@ -109,7 +109,7 @@ pub fn run_condition_yes_with_resource(criterion: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
// run once to initialize systems
|
// run once to initialize systems
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
group.bench_function(&format!("{:03}_systems", 5 * amount + 1), |bencher| {
|
group.bench_function(format!("{:03}_systems", 5 * amount + 1), |bencher| {
|
||||||
bencher.iter(|| {
|
bencher.iter(|| {
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
});
|
});
|
||||||
|
@ -26,7 +26,7 @@ pub fn empty_systems(criterion: &mut Criterion) {
|
|||||||
schedule.add_systems(empty);
|
schedule.add_systems(empty);
|
||||||
}
|
}
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
group.bench_function(&format!("{:03}_systems", amount), |bencher| {
|
group.bench_function(format!("{:03}_systems", amount), |bencher| {
|
||||||
bencher.iter(|| {
|
bencher.iter(|| {
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
});
|
});
|
||||||
@ -38,7 +38,7 @@ pub fn empty_systems(criterion: &mut Criterion) {
|
|||||||
schedule.add_systems((empty, empty, empty, empty, empty));
|
schedule.add_systems((empty, empty, empty, empty, empty));
|
||||||
}
|
}
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
group.bench_function(&format!("{:03}_systems", 5 * amount), |bencher| {
|
group.bench_function(format!("{:03}_systems", 5 * amount), |bencher| {
|
||||||
bencher.iter(|| {
|
bencher.iter(|| {
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
});
|
});
|
||||||
@ -80,7 +80,7 @@ pub fn busy_systems(criterion: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
group.bench_function(
|
group.bench_function(
|
||||||
&format!(
|
format!(
|
||||||
"{:02}x_entities_{:02}_systems",
|
"{:02}x_entities_{:02}_systems",
|
||||||
entity_bunches,
|
entity_bunches,
|
||||||
3 * system_amount + 3
|
3 * system_amount + 3
|
||||||
@ -131,7 +131,7 @@ pub fn contrived(criterion: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
group.bench_function(
|
group.bench_function(
|
||||||
&format!(
|
format!(
|
||||||
"{:02}x_entities_{:02}_systems",
|
"{:02}x_entities_{:02}_systems",
|
||||||
entity_bunches,
|
entity_bunches,
|
||||||
3 * system_amount + 3
|
3 * system_amount + 3
|
||||||
|
@ -74,7 +74,7 @@ pub fn build_schedule(criterion: &mut Criterion) {
|
|||||||
// Method: generate a set of `graph_size` systems which have a One True Ordering.
|
// Method: generate a set of `graph_size` systems which have a One True Ordering.
|
||||||
// Add system to the schedule with full constraints. Hopefully this should be maximally
|
// Add system to the schedule with full constraints. Hopefully this should be maximally
|
||||||
// difficult for bevy to figure out.
|
// difficult for bevy to figure out.
|
||||||
let labels: Vec<_> = (0..1000).map(|i| NumSet(i)).collect();
|
let labels: Vec<_> = (0..1000).map(NumSet).collect();
|
||||||
|
|
||||||
// Benchmark graphs of different sizes.
|
// Benchmark graphs of different sizes.
|
||||||
for graph_size in [100, 500, 1000] {
|
for graph_size in [100, 500, 1000] {
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
use bevy_ecs::entity::{Entity, EntityHashSet};
|
use bevy_ecs::entity::{Entity, EntityHashSet};
|
||||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
|
use criterion::{BenchmarkId, Criterion, Throughput};
|
||||||
use rand::{Rng, SeedableRng};
|
use rand::{Rng, SeedableRng};
|
||||||
use rand_chacha::ChaCha8Rng;
|
use rand_chacha::ChaCha8Rng;
|
||||||
|
|
||||||
criterion_group!(benches, entity_set_build_and_lookup,);
|
|
||||||
criterion_main!(benches);
|
|
||||||
|
|
||||||
const SIZES: [usize; 5] = [100, 316, 1000, 3162, 10000];
|
const SIZES: [usize; 5] = [100, 316, 1000, 3162, 10000];
|
||||||
|
|
||||||
fn make_entity(rng: &mut impl Rng, size: usize) -> Entity {
|
fn make_entity(rng: &mut impl Rng, size: usize) -> Entity {
|
||||||
|
@ -1,25 +1,20 @@
|
|||||||
use criterion::criterion_group;
|
|
||||||
|
|
||||||
mod commands;
|
mod commands;
|
||||||
use commands::*;
|
|
||||||
|
|
||||||
mod despawn;
|
mod despawn;
|
||||||
use despawn::*;
|
|
||||||
|
|
||||||
mod despawn_recursive;
|
mod despawn_recursive;
|
||||||
use despawn_recursive::*;
|
mod entity_hash;
|
||||||
|
|
||||||
mod spawn;
|
mod spawn;
|
||||||
use spawn::*;
|
|
||||||
|
|
||||||
mod world_get;
|
mod world_get;
|
||||||
|
|
||||||
|
use commands::*;
|
||||||
|
use criterion::criterion_group;
|
||||||
|
use despawn::*;
|
||||||
|
use despawn_recursive::*;
|
||||||
|
use entity_hash::*;
|
||||||
|
use spawn::*;
|
||||||
use world_get::*;
|
use world_get::*;
|
||||||
|
|
||||||
mod entity_hash;
|
|
||||||
use entity_hash::*;
|
|
||||||
|
|
||||||
criterion_group!(
|
criterion_group!(
|
||||||
world_benches,
|
benches,
|
||||||
empty_commands,
|
empty_commands,
|
||||||
spawn_commands,
|
spawn_commands,
|
||||||
insert_commands,
|
insert_commands,
|
||||||
@ -39,5 +34,5 @@ criterion_group!(
|
|||||||
query_get_many::<2>,
|
query_get_many::<2>,
|
||||||
query_get_many::<5>,
|
query_get_many::<5>,
|
||||||
query_get_many::<10>,
|
query_get_many::<10>,
|
||||||
entity_set_build_and_lookup
|
entity_set_build_and_lookup,
|
||||||
);
|
);
|
||||||
|
@ -306,7 +306,7 @@ pub fn query_get(criterion: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn query_get_many<const N: usize>(criterion: &mut Criterion) {
|
pub fn query_get_many<const N: usize>(criterion: &mut Criterion) {
|
||||||
let mut group = criterion.benchmark_group(&format!("query_get_many_{N}"));
|
let mut group = criterion.benchmark_group(format!("query_get_many_{N}"));
|
||||||
group.warm_up_time(core::time::Duration::from_millis(500));
|
group.warm_up_time(core::time::Duration::from_millis(500));
|
||||||
group.measurement_time(core::time::Duration::from_secs(2 * N as u64));
|
group.measurement_time(core::time::Duration::from_secs(2 * N as u64));
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, Criterion};
|
||||||
|
|
||||||
use bevy_math::prelude::*;
|
use bevy_math::prelude::*;
|
||||||
|
|
||||||
@ -92,4 +92,3 @@ criterion_group!(
|
|||||||
build_pos_cubic,
|
build_pos_cubic,
|
||||||
build_accel_cubic,
|
build_accel_cubic,
|
||||||
);
|
);
|
||||||
criterion_main!(benches);
|
|
||||||
|
5
benches/benches/bevy_math/main.rs
Normal file
5
benches/benches/bevy_math/main.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
use criterion::criterion_main;
|
||||||
|
|
||||||
|
mod bezier;
|
||||||
|
|
||||||
|
criterion_main!(bezier::benches);
|
5
benches/benches/bevy_picking/main.rs
Normal file
5
benches/benches/bevy_picking/main.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
use criterion::criterion_main;
|
||||||
|
|
||||||
|
mod ray_mesh_intersection;
|
||||||
|
|
||||||
|
criterion_main!(ray_mesh_intersection::benches);
|
@ -1,6 +1,6 @@
|
|||||||
use bevy_math::{Dir3, Mat4, Ray3d, Vec3};
|
use bevy_math::{Dir3, Mat4, Ray3d, Vec3};
|
||||||
use bevy_picking::mesh_picking::ray_cast;
|
use bevy_picking::mesh_picking::ray_cast;
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, Criterion};
|
||||||
|
|
||||||
fn ptoxznorm(p: u32, size: u32) -> (f32, f32) {
|
fn ptoxznorm(p: u32, size: u32) -> (f32, f32) {
|
||||||
let ij = (p / (size), p % (size));
|
let ij = (p / (size), p % (size));
|
||||||
@ -117,4 +117,3 @@ criterion_group!(
|
|||||||
ray_mesh_intersection_no_cull,
|
ray_mesh_intersection_no_cull,
|
||||||
ray_mesh_intersection_no_intersection
|
ray_mesh_intersection_no_intersection
|
||||||
);
|
);
|
||||||
criterion_main!(benches);
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use bevy_reflect::func::{ArgList, IntoFunction, IntoFunctionMut, TypedFunction};
|
use bevy_reflect::func::{ArgList, IntoFunction, IntoFunctionMut, TypedFunction};
|
||||||
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
|
use criterion::{criterion_group, BatchSize, Criterion};
|
||||||
|
|
||||||
criterion_group!(benches, typed, into, call, overload, clone);
|
criterion_group!(benches, typed, into, call, overload, clone);
|
||||||
criterion_main!(benches);
|
|
||||||
|
|
||||||
fn add(a: i32, b: i32) -> i32 {
|
fn add(a: i32, b: i32) -> i32 {
|
||||||
a + b
|
a + b
|
||||||
|
@ -2,8 +2,8 @@ use core::{iter, time::Duration};
|
|||||||
|
|
||||||
use bevy_reflect::{DynamicList, List};
|
use bevy_reflect::{DynamicList, List};
|
||||||
use criterion::{
|
use criterion::{
|
||||||
black_box, criterion_group, criterion_main, measurement::Measurement, BatchSize,
|
black_box, criterion_group, measurement::Measurement, BatchSize, BenchmarkGroup, BenchmarkId,
|
||||||
BenchmarkGroup, BenchmarkId, Criterion, Throughput,
|
Criterion, Throughput,
|
||||||
};
|
};
|
||||||
|
|
||||||
criterion_group!(
|
criterion_group!(
|
||||||
@ -13,7 +13,6 @@ criterion_group!(
|
|||||||
dynamic_list_apply,
|
dynamic_list_apply,
|
||||||
dynamic_list_push
|
dynamic_list_push
|
||||||
);
|
);
|
||||||
criterion_main!(benches);
|
|
||||||
|
|
||||||
const WARM_UP_TIME: Duration = Duration::from_millis(500);
|
const WARM_UP_TIME: Duration = Duration::from_millis(500);
|
||||||
const MEASUREMENT_TIME: Duration = Duration::from_secs(4);
|
const MEASUREMENT_TIME: Duration = Duration::from_secs(4);
|
||||||
|
17
benches/benches/bevy_reflect/main.rs
Normal file
17
benches/benches/bevy_reflect/main.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#![expect(clippy::type_complexity)]
|
||||||
|
|
||||||
|
use criterion::criterion_main;
|
||||||
|
|
||||||
|
mod function;
|
||||||
|
mod list;
|
||||||
|
mod map;
|
||||||
|
mod path;
|
||||||
|
mod r#struct;
|
||||||
|
|
||||||
|
criterion_main!(
|
||||||
|
function::benches,
|
||||||
|
list::benches,
|
||||||
|
map::benches,
|
||||||
|
path::benches,
|
||||||
|
r#struct::benches,
|
||||||
|
);
|
@ -3,8 +3,8 @@ use core::{fmt::Write, iter, time::Duration};
|
|||||||
use bevy_reflect::{DynamicMap, Map};
|
use bevy_reflect::{DynamicMap, Map};
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
use criterion::{
|
use criterion::{
|
||||||
black_box, criterion_group, criterion_main, measurement::Measurement, BatchSize,
|
black_box, criterion_group, measurement::Measurement, BatchSize, BenchmarkGroup, BenchmarkId,
|
||||||
BenchmarkGroup, BenchmarkId, Criterion, Throughput,
|
Criterion, Throughput,
|
||||||
};
|
};
|
||||||
|
|
||||||
criterion_group!(
|
criterion_group!(
|
||||||
@ -14,7 +14,6 @@ criterion_group!(
|
|||||||
dynamic_map_get,
|
dynamic_map_get,
|
||||||
dynamic_map_insert
|
dynamic_map_insert
|
||||||
);
|
);
|
||||||
criterion_main!(benches);
|
|
||||||
|
|
||||||
const WARM_UP_TIME: Duration = Duration::from_millis(500);
|
const WARM_UP_TIME: Duration = Duration::from_millis(500);
|
||||||
const MEASUREMENT_TIME: Duration = Duration::from_secs(4);
|
const MEASUREMENT_TIME: Duration = Duration::from_secs(4);
|
||||||
@ -266,7 +265,7 @@ fn dynamic_map_insert(criterion: &mut Criterion) {
|
|||||||
|mut map| {
|
|mut map| {
|
||||||
for i in 0..size as u64 {
|
for i in 0..size as u64 {
|
||||||
let key = black_box(i);
|
let key = black_box(i);
|
||||||
black_box(map.insert(key, i));
|
map.insert(key, black_box(i));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
BatchSize::SmallInput,
|
BatchSize::SmallInput,
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
use core::{fmt::Write, str, time::Duration};
|
use core::{fmt::Write, str, time::Duration};
|
||||||
|
|
||||||
use bevy_reflect::ParsedPath;
|
use bevy_reflect::ParsedPath;
|
||||||
use criterion::{
|
use criterion::{black_box, criterion_group, BatchSize, BenchmarkId, Criterion, Throughput};
|
||||||
black_box, criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion, Throughput,
|
|
||||||
};
|
|
||||||
use rand::{distributions::Uniform, Rng, SeedableRng};
|
use rand::{distributions::Uniform, Rng, SeedableRng};
|
||||||
use rand_chacha::ChaCha8Rng;
|
use rand_chacha::ChaCha8Rng;
|
||||||
|
|
||||||
criterion_group!(benches, parse_reflect_path);
|
criterion_group!(benches, parse_reflect_path);
|
||||||
criterion_main!(benches);
|
|
||||||
|
|
||||||
const WARM_UP_TIME: Duration = Duration::from_millis(500);
|
const WARM_UP_TIME: Duration = Duration::from_millis(500);
|
||||||
const MEASUREMENT_TIME: Duration = Duration::from_secs(2);
|
const MEASUREMENT_TIME: Duration = Duration::from_secs(2);
|
||||||
@ -20,7 +17,7 @@ fn deterministic_rand() -> ChaCha8Rng {
|
|||||||
ChaCha8Rng::seed_from_u64(42)
|
ChaCha8Rng::seed_from_u64(42)
|
||||||
}
|
}
|
||||||
fn random_ident(rng: &mut ChaCha8Rng, f: &mut dyn Write) {
|
fn random_ident(rng: &mut ChaCha8Rng, f: &mut dyn Write) {
|
||||||
let between = Uniform::try_from(b'a'..=b'z').unwrap();
|
let between = Uniform::from(b'a'..=b'z');
|
||||||
let ident_size = rng.gen_range(1..128);
|
let ident_size = rng.gen_range(1..128);
|
||||||
let ident: Vec<u8> = rng.sample_iter(between).take(ident_size).collect();
|
let ident: Vec<u8> = rng.sample_iter(between).take(ident_size).collect();
|
||||||
let ident = str::from_utf8(&ident).unwrap();
|
let ident = str::from_utf8(&ident).unwrap();
|
||||||
@ -82,9 +79,9 @@ fn parse_reflect_path(criterion: &mut Criterion) {
|
|||||||
BenchmarkId::new("parse_reflect_path", size),
|
BenchmarkId::new("parse_reflect_path", size),
|
||||||
&size,
|
&size,
|
||||||
|bencher, &size| {
|
|bencher, &size| {
|
||||||
let mut mk_paths = mk_paths(size);
|
let mk_paths = mk_paths(size);
|
||||||
bencher.iter_batched(
|
bencher.iter_batched(
|
||||||
|| mk_paths(),
|
mk_paths,
|
||||||
|path| assert!(ParsedPath::parse(black_box(&path)).is_ok()),
|
|path| assert!(ParsedPath::parse(black_box(&path)).is_ok()),
|
||||||
BatchSize::SmallInput,
|
BatchSize::SmallInput,
|
||||||
);
|
);
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
|
|
||||||
use bevy_reflect::{DynamicStruct, GetField, PartialReflect, Reflect, Struct};
|
use bevy_reflect::{DynamicStruct, GetField, PartialReflect, Reflect, Struct};
|
||||||
use criterion::{
|
use criterion::{black_box, criterion_group, BatchSize, BenchmarkId, Criterion, Throughput};
|
||||||
black_box, criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion, Throughput,
|
|
||||||
};
|
|
||||||
|
|
||||||
criterion_group!(
|
criterion_group!(
|
||||||
benches,
|
benches,
|
||||||
@ -16,7 +14,6 @@ criterion_group!(
|
|||||||
dynamic_struct_get_field,
|
dynamic_struct_get_field,
|
||||||
dynamic_struct_insert,
|
dynamic_struct_insert,
|
||||||
);
|
);
|
||||||
criterion_main!(benches);
|
|
||||||
|
|
||||||
const WARM_UP_TIME: Duration = Duration::from_millis(500);
|
const WARM_UP_TIME: Duration = Duration::from_millis(500);
|
||||||
const MEASUREMENT_TIME: Duration = Duration::from_secs(4);
|
const MEASUREMENT_TIME: Duration = Duration::from_secs(4);
|
||||||
@ -316,7 +313,7 @@ fn dynamic_struct_insert(criterion: &mut Criterion) {
|
|||||||
bencher.iter_batched(
|
bencher.iter_batched(
|
||||||
|| s.clone_dynamic(),
|
|| s.clone_dynamic(),
|
||||||
|mut s| {
|
|mut s| {
|
||||||
black_box(s.insert(black_box(&field), ()));
|
s.insert(black_box(&field), ());
|
||||||
},
|
},
|
||||||
BatchSize::SmallInput,
|
BatchSize::SmallInput,
|
||||||
);
|
);
|
||||||
|
6
benches/benches/bevy_render/main.rs
Normal file
6
benches/benches/bevy_render/main.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
use criterion::criterion_main;
|
||||||
|
|
||||||
|
mod render_layers;
|
||||||
|
mod torus;
|
||||||
|
|
||||||
|
criterion_main!(render_layers::benches, torus::benches);
|
@ -1,4 +1,4 @@
|
|||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, Criterion};
|
||||||
|
|
||||||
use bevy_render::view::RenderLayers;
|
use bevy_render::view::RenderLayers;
|
||||||
|
|
||||||
@ -6,14 +6,8 @@ fn render_layers(c: &mut Criterion) {
|
|||||||
c.bench_function("layers_intersect", |b| {
|
c.bench_function("layers_intersect", |b| {
|
||||||
let layer_a = RenderLayers::layer(1).with(2);
|
let layer_a = RenderLayers::layer(1).with(2);
|
||||||
let layer_b = RenderLayers::layer(1);
|
let layer_b = RenderLayers::layer(1);
|
||||||
b.iter(|| {
|
b.iter(|| black_box(layer_a.intersects(&layer_b)));
|
||||||
black_box(layer_a.intersects(&layer_b))
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
criterion_group!(
|
criterion_group!(benches, render_layers);
|
||||||
benches,
|
|
||||||
render_layers,
|
|
||||||
);
|
|
||||||
criterion_main!(benches);
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, Criterion};
|
||||||
|
|
||||||
use bevy_render::mesh::TorusMeshBuilder;
|
use bevy_render::mesh::TorusMeshBuilder;
|
||||||
|
|
||||||
@ -8,5 +8,4 @@ fn torus(c: &mut Criterion) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
criterion_group!(benches, torus,);
|
criterion_group!(benches, torus);
|
||||||
criterion_main!(benches);
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use bevy_tasks::{ParallelIterator, TaskPoolBuilder};
|
use bevy_tasks::{ParallelIterator, TaskPoolBuilder};
|
||||||
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
|
use criterion::{black_box, criterion_group, BenchmarkId, Criterion};
|
||||||
|
|
||||||
struct ParChunks<'a, T>(core::slice::Chunks<'a, T>);
|
struct ParChunks<'a, T>(core::slice::Chunks<'a, T>);
|
||||||
impl<'a, T> ParallelIterator<core::slice::Iter<'a, T>> for ParChunks<'a, T>
|
impl<'a, T> ParallelIterator<core::slice::Iter<'a, T>> for ParChunks<'a, T>
|
||||||
@ -141,4 +141,3 @@ fn bench_many_maps(c: &mut Criterion) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
criterion_group!(benches, bench_overhead, bench_for_each, bench_many_maps);
|
criterion_group!(benches, bench_overhead, bench_for_each, bench_many_maps);
|
||||||
criterion_main!(benches);
|
|
||||||
|
5
benches/benches/bevy_tasks/main.rs
Normal file
5
benches/benches/bevy_tasks/main.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
use criterion::criterion_main;
|
||||||
|
|
||||||
|
mod iter;
|
||||||
|
|
||||||
|
criterion_main!(iter::benches);
|
Loading…
Reference in New Issue
Block a user