pub trait FracPair {
// Required method
fn frac_pair(&self, other: &Self) -> BTreeMap<Phase, f64>;
}Expand description
Per-phase “share of total” reducer. Specialized for the dominant
counter shape (BTreeMap<Phase, u64>) because u64: Into<f64>
is intentionally absent (cast is lossy) — a generic
PhaseMapExt method with an Into<f64> bound would reject
every counter-delta map test authors actually reach for.
For every phase present in BOTH self AND other, computes
self_value as f64 / (self_value + other_value) as f64. When
both values are zero (sum is zero), the phase is dropped from
the result — there is no signal to share, and synthesizing
0.0 would let downstream at_most / ratio_within gates
silently pass on a zero-event phase pair. Returning no entry
surfaces the absence so the consumer can treat it as
Inconclusive (the same shape as a phase only present in one
input). Phases present in only one input also drop from the
result, mirroring PhaseMapExt::zip_per_phase’s
intersection-only semantics; both drop conditions surface
identically as “no entry for this phase.”
Targets the “cross-LLC dispatch fraction” idiom (nr_cross / (nr_cross + nr_same)) and similar share-of-total patterns.
The general fold via PhaseMapExt::zip_per_phase requires
the caller to spell the safe-divide branch inline at every
call site; this trait owns the branch so test code expresses
the metric in one chain.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.