diff options
Diffstat (limited to 'ecs/benches/query_iterating.rs')
-rw-r--r-- | ecs/benches/query_iterating.rs | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/ecs/benches/query_iterating.rs b/ecs/benches/query_iterating.rs deleted file mode 100644 index cfda4a3..0000000 --- a/ecs/benches/query_iterating.rs +++ /dev/null @@ -1,119 +0,0 @@ -use std::hint::black_box; -use std::path::PathBuf; - -use criterion::{criterion_group, criterion_main, Criterion}; -use ecs::{Component, World}; - -fn fibonacci(n: u64) -> u64 -{ - match n { - 0 => 1, - 1 => 1, - n => fibonacci(n - 1) + fibonacci(n - 2), - } -} - -#[derive(Component)] -struct Foo -{ - text: String, -} - -#[derive(Component)] -struct Bar -{ - path: PathBuf, - num: u64, -} - -#[derive(Component)] -struct Position -{ - x: f32, - y: f32, - z: f32, -} - -#[derive(Component)] -struct PosA -{ - x: f32, - y: f32, - z: f32, -} - -#[derive(Component)] -struct PosB -{ - x: f32, - y: f32, - z: f32, -} - -#[derive(Component)] -struct PosC -{ - x: f32, - y: f32, - z: f32, -} - -#[derive(Component)] -struct MoreText -{ - more_text: String, -} - -#[derive(Component)] -struct EvenMoreText -{ - even_more_text: String, -} - -fn criterion_benchmark(criterion: &mut Criterion) -{ - let mut world = World::new(); - - for _ in 0..300 { - world.create_entity(( - Bar { path: "/dev/zero".into(), num: 65789 }, - Position { x: 13.98, y: 27.0, z: 0.2 }, - Foo { text: "Hello there".to_string() }, - PosA { x: 1183.98, y: 272628.0, z: 3306.2 }, - PosB { x: 171183.98, y: 28.0, z: 336.2901 }, - PosC { x: 8273.98, y: 28.0, z: 336.2901 }, - MoreText { more_text: "Lorem ipsum".to_string() }, - EvenMoreText { - even_more_text: "Wow so much text".to_string(), - }, - )); - } - - for _ in 0..700 { - world.create_entity(( - Bar { path: "/dev/null".into(), num: 65789 }, - Position { x: 88.11, y: 9.0, z: 36.11 }, - Foo { text: "Hey".to_string() }, - PosA { x: 118310.98, y: 272628.0, z: 3306.2 }, - PosB { x: 11323.98, y: 28.0, z: 336.2901 }, - PosC { x: 8273.98, y: 21818.0, z: 336.2901 }, - MoreText { more_text: "Lorem ipsum".to_string() }, - EvenMoreText { - even_more_text: "Wow much text".to_string(), - }, - )); - } - - let query = world.query::<(Bar, Position, Foo), ()>(); - - criterion.bench_function("fib 20", |bencher| { - bencher.iter(|| { - for comps in query.iter() { - black_box(comps); - } - }) - }); -} - -criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); |