bench: capture T0 baseline; expose pi/tau accessors; fix div panic

- Promotes Gaussian::pi and Gaussian::tau to public so benches/gaussian.rs
  compiles, then captures baseline numbers for the T0 acceptance gate.
- Fixes the divide bench: g1/g2 panicked (g1 has lower precision than g2;
  cavity requires pi_num >= pi_den). Swapped to g2/g1 (well-defined).

Baseline on Apple M5 Pro:
  Batch::iteration  29.840 µs
  Gaussian::mul      1.568 ns   (vs ~220 ps for add/sub — hot path)
  Gaussian::div      1.572 ns
This commit is contained in:
2026-04-24 06:43:00 +02:00
parent d11d2e8c6b
commit 06d3c886fe
3 changed files with 18 additions and 3 deletions

12
benches/baseline.txt Normal file
View File

@@ -0,0 +1,12 @@
# Baseline numbers captured before T0 changes
# Hardware: lrrr.local / Apple M5 Pro
# Date: 2026-04-24
Batch::iteration 29.840 µs
Gaussian::add 219.58 ps
Gaussian::sub 219.41 ps
Gaussian::mul 1.568 ns
Gaussian::div 1.572 ns
Gaussian::pi 262.89 ps
Gaussian::tau 262.47 ps
Gaussian::pi_tau_combined 219.40 ps

View File

@@ -23,8 +23,11 @@ fn benchmark_gaussian_arithmetic(criterion: &mut Criterion) {
});
// Benchmark division
// NOTE: numerator must have higher precision (smaller sigma) than the
// denominator in this representation; g2 (sigma=1) / g1 (sigma=8.33) is
// well-defined, whereas g1 / g2 underflows and panics in mu_sigma.
criterion.bench_function("Gaussian::div", |bencher| {
bencher.iter(|| g1 / g2);
bencher.iter(|| g2 / g1);
});
// Benchmark natural parameter conversions

View File

@@ -13,7 +13,7 @@ impl Gaussian {
Gaussian { mu, sigma }
}
fn pi(&self) -> f64 {
pub fn pi(&self) -> f64 {
if self.sigma > 0.0 {
self.sigma.powi(-2)
} else {
@@ -21,7 +21,7 @@ impl Gaussian {
}
}
fn tau(&self) -> f64 {
pub fn tau(&self) -> f64 {
if self.sigma > 0.0 {
self.mu * self.pi()
} else {