blob: 554ab158f18edd680aec12a750cb54c1c63c39ef [file] [log] [blame]
Damien Lespiau06f5f702015-06-25 12:07:56 +01001/*
2 * Copyright © 2015 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 */
24
Damien Lespiau087a8d12015-06-26 14:31:58 +010025#ifndef __IGT_STATS_H__
26#define __IGT_STATS_H__
27
Damien Lespiau06f5f702015-06-25 12:07:56 +010028#include <stdint.h>
Damien Lespiauda123ad2015-06-26 18:04:34 +010029#include <stdbool.h>
Damien Lespiau06f5f702015-06-25 12:07:56 +010030
Damien Lespiaua2f6fd32015-06-26 16:57:55 +010031/**
32 * igt_stats_t:
33 * @values: An array containing the pushed values
34 * @n_values: The number of pushed values
35 */
Damien Lespiau06f5f702015-06-25 12:07:56 +010036typedef struct {
37 uint64_t *values;
Damien Lespiau06f5f702015-06-25 12:07:56 +010038 unsigned int n_values;
Damien Lespiaua2f6fd32015-06-26 16:57:55 +010039
40 /*< private >*/
41 unsigned int capacity;
Damien Lespiau3a5cf842015-06-26 17:02:09 +010042 unsigned int is_population : 1;
Damien Lespiau05c10f92015-06-25 23:57:49 +010043 unsigned int mean_variance_valid : 1;
Damien Lespiau1b8997b2015-06-27 15:33:58 +010044 unsigned int sorted_array_valid : 1;
Damien Lespiau4a89a842015-06-27 09:45:42 +010045 uint64_t min, max;
Damien Lespiau05c10f92015-06-25 23:57:49 +010046 double mean, variance;
Damien Lespiau1b8997b2015-06-27 15:33:58 +010047 uint64_t *sorted;
Damien Lespiau06f5f702015-06-25 12:07:56 +010048} igt_stats_t;
49
Damien Lespiau66e0bf62015-06-27 17:49:40 +010050void igt_stats_init(igt_stats_t *stats);
51void igt_stats_init_with_size(igt_stats_t *stats, unsigned int capacity);
Damien Lespiau06f5f702015-06-25 12:07:56 +010052void igt_stats_fini(igt_stats_t *stats);
Damien Lespiauda123ad2015-06-26 18:04:34 +010053bool igt_stats_is_population(igt_stats_t *stats);
Damien Lespiau3a5cf842015-06-26 17:02:09 +010054void igt_stats_set_population(igt_stats_t *stats, bool full_population);
Damien Lespiau06f5f702015-06-25 12:07:56 +010055void igt_stats_push(igt_stats_t *stats, uint64_t value);
Damien Lespiau3839bac2015-06-27 15:32:23 +010056void igt_stats_push_array(igt_stats_t *stats,
57 const uint64_t *values, unsigned int n_values);
Damien Lespiau4a89a842015-06-27 09:45:42 +010058uint64_t igt_stats_get_min(igt_stats_t *stats);
59uint64_t igt_stats_get_max(igt_stats_t *stats);
Damien Lespiau0e4c1752015-06-27 11:12:01 +010060uint64_t igt_stats_get_range(igt_stats_t *stats);
Damien Lespiau1b8997b2015-06-27 15:33:58 +010061void igt_stats_get_quartiles(igt_stats_t *stats,
62 double *q1, double *q2, double *q3);
Damien Lespiaufabde382015-06-27 15:49:26 +010063double igt_stats_get_iqr(igt_stats_t *stats);
Chris Wilson19135a32015-07-01 13:50:02 +010064double igt_stats_get_iqm(igt_stats_t *stats);
Damien Lespiaue55a11d2015-06-25 23:44:20 +010065double igt_stats_get_mean(igt_stats_t *stats);
Chris Wilson2d305f62015-07-01 18:52:46 +010066double igt_stats_get_trimean(igt_stats_t *stats);
Damien Lespiau1b8997b2015-06-27 15:33:58 +010067double igt_stats_get_median(igt_stats_t *stats);
Damien Lespiau05c10f92015-06-25 23:57:49 +010068double igt_stats_get_variance(igt_stats_t *stats);
Damien Lespiau515cec12015-06-25 23:59:21 +010069double igt_stats_get_std_deviation(igt_stats_t *stats);
Damien Lespiau087a8d12015-06-26 14:31:58 +010070
71#endif /* __IGT_STATS_H__ */