`changes(v range-vector)` — number of times the value changed.
(samples: &[Sample])
| 172 | |
| 173 | /// `changes(v range-vector)` — number of times the value changed. |
| 174 | pub fn changes(samples: &[Sample]) -> Option<f64> { |
| 175 | if samples.len() < 2 { |
| 176 | return Some(0.0); |
| 177 | } |
| 178 | let count = samples |
| 179 | .windows(2) |
| 180 | .filter(|w| (w[1].value - w[0].value).abs() > f64::EPSILON) |
| 181 | .count(); |
| 182 | Some(count as f64) |
| 183 | } |
| 184 | |
| 185 | /// `resets(v range-vector)` — number of counter resets (value decreases). |
| 186 | pub fn resets(samples: &[Sample]) -> Option<f64> { |
no test coverage detected