18 Commits

Author SHA1 Message Date
Chris Wilson
0705ce6d15 igt/stats: Fixup tests to compile after interface changes
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-07-19 18:19:29 +01:00
Damien Lespiau
46f277b90b stats: Exercise the reallocation paths
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 19:05:41 +01:00
Damien Lespiau
66e0bf66da stats: Spwan igt_init_with_size() from igt_init()
It's all about good looking APIs.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 19:05:41 +01:00
Damien Lespiau
817ea87b6e stats: Test we do correctly invalidate the sorted array
Chris had a doubt, and I was lazy and didn't do a similar test for the
quartiles/median than for the mean (test_invalidate_mean()). Plug that
gap.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:46:37 +01:00
Damien Lespiau
fabde384a3 stats: Add support for the interquartile range (IQR)
IQR is a good measure of dispersion.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:08 +01:00
Damien Lespiau
1b8997b3f8 stats: Add support for quartiles (and thus median)
More stuff, quite useful characteristics of a dataset.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:08 +01:00
Damien Lespiau
2fe286985f stats: Use igt_assert_eq_double() when asserting on doubles
Lucky enough to have exact values, == works!

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:08 +01:00
Damien Lespiau
0e4c175e04 stats: Add igt_stats_get_range()
Somewhat useful, for instance to size an histogram.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Damien Lespiau
4a89a841a1 stats: Add functions to retrieve min/max values of the dataset
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Damien Lespiau
87009f3d7b stats: Factor out a fixture to initialize stats
We're going to use this simple fixture once more, might as well make a
function instead of copy/pasting code.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Damien Lespiau
da123adeae stats: Add a getter for the population property
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Damien Lespiau
3a5cf84317 stats: Add a way to specify if the data set is a population or a sample
This changes how we compute the variance. We want an unbiased variance
when reasoning about a sample.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Damien Lespiau
203c3841fc stats: Zero the whole structure at init() time
Because the structure started small, I initialized every member
directly, but that means that the new fields added weren't properly
initialized (sigh!). Zero the whole thing first then.

Also, the punishment for introducing a bug should be to write the
corresponding unit test. It's not a perfect one, but I'll take it.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:04:07 +01:00
Damien Lespiau
76ea7b9133 tests/stats: Make sure we properly invalidate the cached mean
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@intel.com>
2015-06-27 16:03:27 +01:00
Damien Lespiau
515cec1210 stats: Add a way to retrieve the standard deviation
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:03:27 +01:00
Damien Lespiau
9986282c2b tests/igt_stats: Call igt_stats_fini() to not leak the array
Sure, it'll be freed at exit(), but might as well be a bit pedantic.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:03:27 +01:00
Damien Lespiau
e55a11d3eb stats: Be more precise and talk about mean, not average
There are several types of averages eg. mean, median and mode.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-27 16:03:27 +01:00
Damien Lespiau
06f5f7065f lib: Add a tiny utility function to compute averages
The master plan would be to get a bit more stats in it, at least the
standard deviation and confidence interval. Just need the average for
now.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2015-06-25 17:22:03 +01:00