MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / sample_stdev

Function sample_stdev

crates/runner-shared/src/walltime_results/stats.rs:108–122  ·  view source on GitHub ↗

Calculate sample standard deviation (n-1 denominator). This is intended to match pytest-codspeed's computation, which uses python's statistics.stdev

(data: &[f64], mean: f64)

Source from the content-addressed store, hash-verified

106/// This is intended to match pytest-codspeed's computation, which uses python's
107/// statistics.stdev
108fn sample_stdev(data: &[f64], mean: f64) -> f64 {
109 let n = data.len();
110 if n <= 1 {
111 return 0.0;
112 }
113 let variance: f64 = data
114 .iter()
115 .map(|&t| {
116 let diff = t - mean;
117 diff * diff
118 })
119 .sum::<f64>()
120 / (n - 1) as f64;
121 variance.sqrt()
122}
123
124/// Calculate quantile with linear interpolation.
125/// This is intended to match pytest-codspeed's computation, which uses python's

Callers 1

from_runtime_dataMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected