[Intel-gfx] [PATCH i-g-t 5/5] tests/stats: Make sure we properly invalidate the cached mean
Damien Lespiau
damien.lespiau at intel.com
Thu Jun 25 16:26:59 PDT 2015
Sure, that's an implementation details, but make sure we do recompute
the mean when we add a new value.
Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
lib/tests/igt_stats.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/lib/tests/igt_stats.c b/lib/tests/igt_stats.c
index 172e4b3..f9081c7 100644
--- a/lib/tests/igt_stats.c
+++ b/lib/tests/igt_stats.c
@@ -45,6 +45,30 @@ static void test_mean(void)
igt_stats_fini(&stats);
}
+static void test_invalidate_mean(void)
+{
+ igt_stats_t stats;
+ double mean1, mean2;
+
+ igt_stats_init(&stats, 6);
+
+ igt_stats_push(&stats, 2);
+ igt_stats_push(&stats, 4);
+ igt_stats_push(&stats, 6);
+ igt_stats_push(&stats, 8);
+ igt_stats_push(&stats, 10);
+
+ mean1 = igt_stats_get_mean(&stats);
+ igt_assert(mean1 == (2 + 4 + 6 + 8 + 10) / 5.);
+
+ igt_stats_push(&stats, 100);
+
+ mean2 = igt_stats_get_mean(&stats);
+ igt_assert(mean1 != mean2);
+
+ igt_stats_fini(&stats);
+}
+
/*
* Taken from the "Basic examples" section of:
* https://en.wikipedia.org/wiki/Standard_deviation
@@ -80,5 +104,6 @@ static void test_std_deviation(void)
igt_simple_main
{
test_mean();
+ test_invalidate_mean();
test_std_deviation();
}
--
2.1.0
More information about the Intel-gfx
mailing list