diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-05-26 05:22:25 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:10:02 +0300 |
commit | 65bc41090720cdc249c1b0b9b9b8a8f062b41268 (patch) | |
tree | bbbe6c8d8cd02026e3896e938dae686f74dea812 /fs/bcachefs/mean_and_variance.h | |
parent | aab5e0972a32790c0dbfac64929529820114c674 (diff) | |
download | linux-65bc41090720cdc249c1b0b9b9b8a8f062b41268.tar.xz |
mean and variance: More tests
Add some more tests that test conventional and weighted mean
simultaneously, and with a table of values that represents events that
we'll be using this to look for so we can verify-by-eyeball that the
output looks sane.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/mean_and_variance.h')
-rw-r--r-- | fs/bcachefs/mean_and_variance.h | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/bcachefs/mean_and_variance.h b/fs/bcachefs/mean_and_variance.h index 880e9501c614..6dd4c050e78a 100644 --- a/fs/bcachefs/mean_and_variance.h +++ b/fs/bcachefs/mean_and_variance.h @@ -176,14 +176,12 @@ static inline s64 fast_divpow2(s64 n, u8 d) * * see linked pdf equation 12. */ -static inline struct mean_and_variance -mean_and_variance_update(struct mean_and_variance s, s64 v) -{ - return (struct mean_and_variance) { - .n = s.n + 1, - .sum = s.sum + v, - .sum_squares = u128_add(s.sum_squares, u128_square(abs(v))), - }; +static inline void +mean_and_variance_update(struct mean_and_variance *s, s64 v) +{ + s->n++; + s->sum += v; + s->sum_squares = u128_add(s->sum_squares, u128_square(abs(v))); } s64 mean_and_variance_get_mean(struct mean_and_variance s); |