Allow or fix dead code in benches (#16282)

# Objective

Fixes #15806

## Solution

Fix an undeclared module and expect `dead_code`.

## Testing

Run this command and see no `dead_code` warnings.

`cargo +nightly check --benches --target-dir ../target --manifest-path
./benches/Cargo.toml`
This commit is contained in:
Benjamin Brienen 2024-11-07 23:19:07 +01:00 committed by GitHub
parent f754cecb49
commit 4df8b1998e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 7 deletions

View file

@ -1,3 +1,5 @@
#![expect(dead_code, reason = "Many fields are unused/unread as they are just for benchmarking purposes.")]
use criterion::criterion_main;
mod components;

View file

@ -1,6 +1,6 @@
use bevy::prelude::*;
use bevy_ecs::prelude::*;
#[derive(Component)]
#[derive(Component, Clone)]
struct A(f32);
#[derive(Component)]
struct B(f32);
@ -12,19 +12,18 @@ impl Benchmark {
let mut world = World::default();
let entities = world
.spawn_batch((0..10000).map(|_| A(0.0)))
.collect::<Vec<_>>();
.spawn_batch(core::iter::repeat(A(0.)).take(10000))
.collect();
Self(world, entities)
}
pub fn run(&mut self) {
for entity in &self.1 {
self.0.insert_one(*entity, B(0.0)).unwrap();
self.0.entity_mut(*entity).insert(B(0.));
}
for entity in &self.1 {
self.0.remove_one::<B>(*entity).unwrap();
self.0.entity_mut(*entity).remove::<B>();
}
}
}

View file

@ -5,6 +5,7 @@ mod add_remove_big_table;
mod add_remove_sparse_set;
mod add_remove_table;
mod add_remove_very_big_table;
mod add_remove;
mod archetype_updates;
mod insert_simple;
mod insert_simple_unbatched;