From 06f5f7065fccc5fbb9f65f6f7d348624e2fa0d2b Mon Sep 17 00:00:00 2001 From: Damien Lespiau Date: Thu, 25 Jun 2015 12:07:56 +0100 Subject: 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 --- lib/igt_stats.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 lib/igt_stats.h (limited to 'lib/igt_stats.h') diff --git a/lib/igt_stats.h b/lib/igt_stats.h new file mode 100644 index 00000000..99dc1c9e --- /dev/null +++ b/lib/igt_stats.h @@ -0,0 +1,36 @@ +/* + * Copyright © 2015 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include + +typedef struct { + uint64_t *values; + unsigned int capacity; + unsigned int n_values; +} igt_stats_t; + +void igt_stats_init(igt_stats_t *stats, unsigned int capacity); +void igt_stats_fini(igt_stats_t *stats); +void igt_stats_push(igt_stats_t *stats, uint64_t value); +double igt_stats_get_average(igt_stats_t *stats); -- cgit v1.2.3