mirror of
https://github.com/bevyengine/bevy
synced 2024-12-29 22:43:14 +00:00
chore: fix several clippy lints
This commit is contained in:
parent
afc8d33a87
commit
d6cdf960ab
10 changed files with 26 additions and 23 deletions
|
@ -95,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;
|
||||||
}
|
}
|
||||||
|
@ -143,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;
|
||||||
}
|
}
|
||||||
|
@ -195,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);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -237,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;
|
||||||
}
|
}
|
||||||
|
@ -341,7 +341,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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,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());
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
dead_code,
|
dead_code,
|
||||||
reason = "Many fields are unused/unread as they are just for benchmarking purposes."
|
reason = "Many fields are unused/unread as they are just for benchmarking purposes."
|
||||||
)]
|
)]
|
||||||
|
#![expect(clippy::type_complexity)]
|
||||||
|
|
||||||
use criterion::criterion_main;
|
use criterion::criterion_main;
|
||||||
|
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
|
@ -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] {
|
||||||
|
|
|
@ -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,3 +1,5 @@
|
||||||
|
#![expect(clippy::type_complexity)]
|
||||||
|
|
||||||
use criterion::criterion_main;
|
use criterion::criterion_main;
|
||||||
|
|
||||||
mod function;
|
mod function;
|
||||||
|
|
|
@ -17,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();
|
||||||
|
@ -79,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,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue