pub fn reset()Expand description
Clears the counters, and lowers every thread’s recorded peak to the last depth observed for it.
Concurrency note: reset writes many counters belonging to many threads,
and is not synchronized with any of them. While one is in flight:
- an observation may land on a counter that is about to be cleared, and be lost, or on one just cleared, and survive;
- a snapshot may be internally incoherent — most visibly,
Stats::sample_avgcan exceedStats::peak_max, because the samples and the peak they came from were cleared at different moments.
A peak may also be re-learned immediately afterwards: only the owner of a stack can repaint it, so the marks left by an earlier deep excursion are still there for the next scan to find.
For measuring a specific operation, prefer crate::measure, which diffs
snapshots instead of touching shared state
, or crate::measure_peak, which repaints.