You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The data validity checks that were used in the default implementation (added in #49) significantly slow the calculation of a harmonic mean with f32 and f64 data (Criterion benchmarks added in the same PR).
Consider adding an unchecked version that is more performant and assumes data validation by the user. Perhaps under an optional feature and not part of the default crate distribution. Panics will occur with zero values. Use of values < 0.0 will not panic, but return f32 or f64 values that are not valid geometric means.
A refactor to:
let sum_of_reciprocal = self.components.iter().copied().map(|x| x.powi(-1)).sum::<T>();
in place of the #49 approach improves execution time from:
Vector mean_harmonic method: f64 5D Vector
time: [4.6057 ns 4.6161 ns 4.6294 ns]
change: [+0.0120% +0.2572% +0.5116%] (p = 0.04 < 0.05)
Change within noise threshold.
Found 5 outliers among 100 measurements (5.00%)
5 (5.00%) high severe
to:
Vector mean_harmonic method: f64 5D Vector
time: [542.75 ps 543.07 ps 543.48 ps]
change: [-88.222% -88.193% -88.164%] (p = 0.00 < 0.05)
Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
3 (3.00%) high mild
8 (8.00%) high severe
The data validity checks that were used in the default implementation (added in #49) significantly slow the calculation of a harmonic mean with f32 and f64 data (Criterion benchmarks added in the same PR).
Consider adding an unchecked version that is more performant and assumes data validation by the user. Perhaps under an optional feature and not part of the default crate distribution. Panics will occur with zero values. Use of values < 0.0 will not panic, but return f32 or f64 values that are not valid geometric means.
A refactor to:
in place of the #49 approach improves execution time from:
to:
The f32 benchmark changes are comparable.
Test environment:
MBP 16" 2021
Apple M1 Max
32GB RAM
macOS 12.1
related #44
related #8
The text was updated successfully, but these errors were encountered: