use multiple components for iteration benchmark
authoralfadur
Sun, 26 Mar 2023 20:55:19 +0300
changeset 15943 feb7a76915d2
parent 15942 bcd43b90401a
child 15944 ccd458b08113
use multiple components for iteration benchmark
rust/hwphysics/benches/ecs_bench.rs
--- a/rust/hwphysics/benches/ecs_bench.rs	Sun Mar 26 06:06:14 2023 +0300
+++ b/rust/hwphysics/benches/ecs_bench.rs	Sun Mar 26 20:55:19 2023 +0300
@@ -33,17 +33,21 @@
 
 pub fn component_run(c: &mut Criterion) {
     let mut manager = GearDataManager::new();
-    manager.register::<Pv>();
+
+    manager.register::<P>();
+    manager.register::<V>();
+
     for i in 1..=SIZE {
         let gear_id = GearId::new(i as u16).unwrap();
-        manager.add(gear_id, &Pv::default());
+        manager.add(gear_id, &P::default());
+        manager.add(gear_id, &V::default());
     }
 
     c.bench_function("component run", |b| {
         b.iter(|| {
             manager
                 .iter()
-                .run(|(item,): (&mut Pv,)| item.velocity += black_box(item.position));
+                .run(|(p, v): (&mut P, &mut V)| v.velocity += black_box(p.position));
         })
     });
 }