pub struct PairedTiming {
pub a_ns: Vec<f64>,
pub b_ns: Vec<f64>,
pub ratios: Vec<f64>,
pub a_went_first: Vec<bool>,
}Expand description
Paired per-repetition timings for two implementations of one computation.
a_ns[i] and b_ns[i] were measured adjacent in time within repetition i,
in an order chosen by the repetition’s coin flip. ratios[i] is
b_ns[i] / a_ns[i], so a value above 1 means A is faster — the same
orientation as the hand_over_production token these gates already print.
Fields§
§a_ns: Vec<f64>Nanoseconds per iteration for arm A, one entry per repetition.
b_ns: Vec<f64>Nanoseconds per iteration for arm B, one entry per repetition.
ratios: Vec<f64>b_ns[i] / a_ns[i], one entry per repetition. Above 1 ⇒ A faster.
a_went_first: Vec<bool>true when arm A was timed first in that repetition.
Implementations§
Source§impl PairedTiming
impl PairedTiming
Sourcepub fn median_ratio(&self) -> f64
pub fn median_ratio(&self) -> f64
Median of the paired ratios — the headline estimate.
The median rather than the mean because a single descheduled repetition produces an arbitrarily large outlier in one direction only, and rather than a minimum because a minimum is the statistic that preserves a systematic offset (see the module docs).
Sourcepub fn wins_fraction(&self) -> f64
pub fn wins_fraction(&self) -> f64
Fraction of repetitions in which A was faster than B.
This is the gate’s honesty check. A median ratio of 1.06 with a wins fraction of 1.0 is a real effect; the same 1.06 with 0.55 means the repetitions disagree with each other and the point estimate is riding on a few draws.
Sourcepub fn ratio_resolution(&self) -> f64
pub fn ratio_resolution(&self) -> f64
Half the central 90% span of the paired ratios, as a fraction of the median — the gate’s own resolution.
A claimed margin smaller than this is not measurable by this harness at this repetition count, and asserting it is asserting noise. Report it beside the margin so the comparison is visible.
Sourcepub fn first_position_bias(&self) -> f64
pub fn first_position_bias(&self) -> f64
Median ratio among repetitions where A ran first, minus the median among those where B ran first.
This is the diagnostic the old harnesses could not produce, because they
never varied the order. A value near zero says position does not matter
on this host; a large value says the measurement is dominated by
whichever arm goes first, and no ordering of a non-randomised harness
would have been trustworthy. Returns NaN if either group is empty.
Sourcepub fn summary(&self, a_label: &str, b_label: &str) -> String
pub fn summary(&self, a_label: &str, b_label: &str) -> String
One line carrying everything needed to audit the verdict, including the numbers that would reveal the verdict as unsupported.
Examples found in repository?
91fn main() {
92 let input: [f64; 17] = std::array::from_fn(|index| 0.35 + 0.07 * (index as f64 + 1.0).sin());
93 for (compiled, canonical) in compiled_bundle4(input).iter().zip(canonical_bundle4(input).iter()) {
94 assert!((compiled - canonical).abs() <= 1e-12 * canonical.abs().max(1.0));
95 }
96 let timing = paired_interleaved(
97 15,
98 2_000,
99 0x9320_AB,
100 batched(64, |nudge| {
101 let mut x = input;
102 x[4] += nudge;
103 compiled_bundle4(x).iter().sum()
104 }),
105 batched(64, |nudge| {
106 let mut x = input;
107 x[4] += nudge;
108 canonical_bundle4(x).iter().sum()
109 }),
110 );
111 println!("{}", timing.summary("compiled_bundle4", "nine_top_channels"));
112 // The two contracts a gate can carry, printed the way a gate prints them.
113 let mut gate = SpeedGate::open("PAIRED-TIMING-REPORT");
114 gate.faster("order=4 bundle", &timing, "compiled_bundle4", "nine_top_channels");
115 gate.not_slower("order=4 bundle", &timing, "compiled_bundle4", "nine_top_channels");
116 gate.finish();
117}Trait Implementations§
Source§impl Clone for PairedTiming
impl Clone for PairedTiming
Source§fn clone(&self) -> PairedTiming
fn clone(&self) -> PairedTiming
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PairedTiming
impl RefUnwindSafe for PairedTiming
impl Send for PairedTiming
impl Sync for PairedTiming
impl Unpin for PairedTiming
impl UnsafeUnpin for PairedTiming
impl UnwindSafe for PairedTiming
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.