From 53cafb6802983cfde9d5e40c2924990e5b5859a8 Mon Sep 17 00:00:00 2001 From: "@permadeath.com" Date: Wed, 19 Aug 2026 23:52:44 -0400 Subject: [PATCH] test(unit-rules): put the newer operations on the speed ratchet The repair list, the upload check and both ways of wearing a design down. The searches are the expensive ones - 21 times a design read to wear to a figure and 37 for a battle, each being dozens of scorings rather than one - which is worth having recorded before something tries to run one per frame. --- TODO.md | 6 ++++ crates/helm-bv/performance.txt | 4 +++ crates/helm-bv/tests/performance.rs | 46 +++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/TODO.md b/TODO.md index 489e302..b6803e4 100644 --- a/TODO.md +++ b/TODO.md @@ -399,6 +399,12 @@ The long pole, and the reason `helm-core` does no I/O. Tracked as its fastest round, because a shared machine has a floor and no ceiling. Run-to-run drift is then under a tenth, against a gate of a fifth. + Nine operations now, not five: the repair list, the upload check, and + both ways of wearing a design down. The two searches are the expensive + ones by a long way - wearing to a figure is 21 times a design read and a + battle is 37, because each is dozens of scorings rather than one - which + is worth having recorded before anything tries to run one per frame. + Held only in release: an unoptimised build is several times slower and the two sets of figures are not comparable, so a debug run prints them and checks nothing. `HELM_PERF_BLESS=1` re-records, and a commit that diff --git a/crates/helm-bv/performance.txt b/crates/helm-bv/performance.txt index af5b6ab..3f25cdd 100644 --- a/crates/helm-bv/performance.txt +++ b/crates/helm-bv/performance.txt @@ -15,3 +15,7 @@ read a design 1.000 # 187576ns here score a design 1.652 # 309941ns here score a damaged design 1.669 # 313115ns here attribute a damaged design 3.252 # 406012ns here +repair a damaged design 0.009 # 1004ns here +check one machine 1.618 # 180500ns here +wear to a figure 21.462 # 2394000ns here +wear in a battle 36.892 # 4115000ns here diff --git a/crates/helm-bv/tests/performance.rs b/crates/helm-bv/tests/performance.rs index 73aec45..b4b5816 100644 --- a/crates/helm-bv/tests/performance.rs +++ b/crates/helm-bv/tests/performance.rs @@ -169,6 +169,52 @@ fn nothing_has_got_materially_slower() { ); }), }, + Task { + what: "repair a damaged design", + iterations: 500, + work: Box::new(|| { + std::hint::black_box(helm_bv::repairs(atlas, &damaged)); + }), + }, + Task { + what: "check one machine", + iterations: 500, + work: Box::new(|| { + std::hint::black_box(helm_bv::check( + Some(atlas), + &inputs.catalogue, + &helm_unitfile::MulUnit { + chassis: "Atlas".into(), + model: "AS7-D".into(), + gunnery: 4, + piloting: 5, + ..Default::default() + }, + )); + }), + }, + Task { + what: "wear to a figure", + iterations: 60, + work: Box::new(|| { + std::hint::black_box(helm_bv::wear_to(atlas, &inputs.catalogue, 1500).ok()); + }), + }, + Task { + what: "wear in a battle", + iterations: 40, + work: Box::new(|| { + std::hint::black_box( + helm_bv::wear_in_battle( + atlas, + &inputs.catalogue, + 1500, + &helm_bv::Battle::default(), + ) + .ok(), + ); + }), + }, Task { what: "attribute a damaged design", iterations: 500, -- 2.51.2