Trait Timings
pub trait Timings: Send + Sync {
// Required methods
fn points(&self) -> Vec<PointTimings>;
fn point(&self, point: &str) -> Option<PointTimings>;
fn reset(&self);
fn add_budget_sink(&self, sink: Arc<dyn Fn(&OverBudget) + Sync + Send>);
}Expand description
A capability of a bus (BusTimings::timings): how long listeners take,
per point and per listener, and the passes over a point’s budget
(PointSpec::budget) reported as they happen.
A pass is what the listeners of one emit ran on one thread: the
inline part of an alter or collect emit, one emit’s local listeners
run by Bus::run_pending, or one ask run by the defer contract’s drain. Its
time is its listeners’ times added up.
What an implementation promises:
- Every listener run it makes is timed, whatever its outcome (a
threaded listener that misses its deadline counts the time the
emit waited), and counted in the listener’s and the pass’s
TimingStatsuntilTimings::reset. - A pass of a point with a budget that takes longer is reported to
the budget sinks, on the thread that ran it, after the pass, with
each listener’s time (
OverBudget). The pass’s results are kept: a budget is not a deadline, and a pass over it is not a failure. - Quantiles may be approximate; counts, totals and maxima are exact.
- Timing costs little next to a listener: clock reads and counters, no allocation per run.
Required Methods§
fn points(&self) -> Vec<PointTimings>
fn points(&self) -> Vec<PointTimings>
Every point that ran a pass since the last reset, in id order.
fn point(&self, point: &str) -> Option<PointTimings>
fn point(&self, point: &str) -> Option<PointTimings>
The timings of the point point; None when it ran no pass
since the last reset.
fn reset(&self)
fn reset(&self)
Starts a new window: every count back to zero (after a start-up phase, before a measured run).
fn add_budget_sink(&self, sink: Arc<dyn Fn(&OverBudget) + Sync + Send>)
fn add_budget_sink(&self, sink: Arc<dyn Fn(&OverBudget) + Sync + Send>)
Adds a sink called with each pass over its point’s budget, on the
thread that ran it: where the host publishes its
OVER_BUDGET_FACT fact or logs. A sink that panics is ignored.
Implementations§
§impl<'a> dyn Timings + 'a
impl<'a> dyn Timings + 'a
pub fn on_over_budget(&self, sink: impl Fn(&OverBudget) + Send + Sync + 'static)
pub fn on_over_budget(&self, sink: impl Fn(&OverBudget) + Send + Sync + 'static)
Adds a sink called with each pass over its point’s budget
(Timings::add_budget_sink).