diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-07-27 14:04:17 +0200 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-07-27 15:43:25 +0200 |
commit | 4755804c56ffe16440edf5e9874234b4ed1c733d (patch) | |
tree | 1c1788ec3d99f5b6c57a1177aa9b996fcfcd47df /lib/igt_stats.c | |
parent | 1260564c191a2e2de44b3ffb66ff68e72cd031dd (diff) |
lib: Update docs for igt_stats
Unfortunately gtkdoc refuses to acknowledge static inlines, so need
to nuke them. It probably gets confused by that static ...
Also unamed unions confuse gtk-doc, move everything else public up.
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'lib/igt_stats.c')
-rw-r--r-- | lib/igt_stats.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/igt_stats.c b/lib/igt_stats.c index 78db6be11..0fbf712c0 100644 --- a/lib/igt_stats.c +++ b/lib/igt_stats.c @@ -606,3 +606,57 @@ double igt_stats_get_trimean(igt_stats_t *stats) igt_stats_get_quartiles(stats, &q1, &q2, &q3); return (q1 + 2*q2 + q3) / 4; } + +/** + * igt_mean_init: + * @m: tracking structure + * + * Initializes or resets @m. + */ +void igt_mean_init(struct igt_mean *m) +{ + memset(m, 0, sizeof(*m)); + m->max = -HUGE_VAL; + m->min = HUGE_VAL; +} + +/** + * igt_mean_add: + * @m: tracking structure + * @v: value + * + * Adds a new value @v to @m. + */ +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); + if (v < m->min) + m->min = v; + if (v > m->max) + m->max = v; +} + +/** + * igt_mean_get: + * @m: tracking structure + * + * Computes the current mean of the samples tracked in @m. + */ +double igt_mean_get(struct igt_mean *m) +{ + return m->mean; +} + +/** + * igt_mean_get_variance: + * @m: tracking structure + * + * Computes the current variance of the samples tracked in @m. + */ +double igt_mean_get_variance(struct igt_mean *m) +{ + return m->sq / m->count; +} + |