diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-03-08 14:10:56 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-03-08 14:58:59 +0000 |
commit | 74761382b3cf4093da4d10a7b92d25721ad92fc7 (patch) | |
tree | 645841cd2febc4a021999873cb3f55c6ad800e8d /lib/igt_stats.h | |
parent | 3a7325e4989352c7a3150628e0f941573dffbf62 (diff) |
benchmarks/gem_latency: Replace igt_stats with igt_mean
Use a simpler statically allocated struct for computing the mean as
otherwise we many run out of memeory!
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_stats.h')
-rw-r--r-- | lib/igt_stats.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/igt_stats.h b/lib/igt_stats.h index ec898b24..105f3fb2 100644 --- a/lib/igt_stats.h +++ b/lib/igt_stats.h @@ -80,4 +80,31 @@ double igt_stats_get_median(igt_stats_t *stats); double igt_stats_get_variance(igt_stats_t *stats); double igt_stats_get_std_deviation(igt_stats_t *stats); +struct igt_mean { + double mean, sq; + unsigned long count; +}; + +static inline void igt_mean_init(struct igt_mean *m) +{ + memset(m, 0, sizeof(*m)); +} + +static inline void igt_mean_add(struct igt_mean *m, double v) +{ + double delta = v - m->mean; + m->mean += delta / m->count++; + m->sq += delta * (v - m->mean); +} + +static inline double igt_mean_get(struct igt_mean *m) +{ + return m->mean; +} + +static inline double igt_mean_get_variance(struct igt_mean *m) +{ + return m->sq / m->count; +} + #endif /* __IGT_STATS_H__ */ |