Damien Lespiau | 06f5f70 | 2015-06-25 12:07:56 +0100 | [diff] [blame] | 1 | /* |
| 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 Lespiau | 087a8d1 | 2015-06-26 14:31:58 +0100 | [diff] [blame] | 25 | #ifndef __IGT_STATS_H__ |
| 26 | #define __IGT_STATS_H__ |
| 27 | |
Damien Lespiau | 06f5f70 | 2015-06-25 12:07:56 +0100 | [diff] [blame] | 28 | #include <stdint.h> |
Damien Lespiau | da123ad | 2015-06-26 18:04:34 +0100 | [diff] [blame] | 29 | #include <stdbool.h> |
Damien Lespiau | 06f5f70 | 2015-06-25 12:07:56 +0100 | [diff] [blame] | 30 | |
Damien Lespiau | a2f6fd3 | 2015-06-26 16:57:55 +0100 | [diff] [blame] | 31 | /** |
| 32 | * igt_stats_t: |
| 33 | * @values: An array containing the pushed values |
| 34 | * @n_values: The number of pushed values |
| 35 | */ |
Damien Lespiau | 06f5f70 | 2015-06-25 12:07:56 +0100 | [diff] [blame] | 36 | typedef struct { |
| 37 | uint64_t *values; |
Damien Lespiau | 06f5f70 | 2015-06-25 12:07:56 +0100 | [diff] [blame] | 38 | unsigned int n_values; |
Damien Lespiau | a2f6fd3 | 2015-06-26 16:57:55 +0100 | [diff] [blame] | 39 | |
| 40 | /*< private >*/ |
| 41 | unsigned int capacity; |
Damien Lespiau | 3a5cf84 | 2015-06-26 17:02:09 +0100 | [diff] [blame] | 42 | unsigned int is_population : 1; |
Damien Lespiau | 05c10f9 | 2015-06-25 23:57:49 +0100 | [diff] [blame] | 43 | unsigned int mean_variance_valid : 1; |
Damien Lespiau | 1b8997b | 2015-06-27 15:33:58 +0100 | [diff] [blame] | 44 | unsigned int sorted_array_valid : 1; |
Damien Lespiau | 4a89a84 | 2015-06-27 09:45:42 +0100 | [diff] [blame] | 45 | uint64_t min, max; |
Damien Lespiau | 05c10f9 | 2015-06-25 23:57:49 +0100 | [diff] [blame] | 46 | double mean, variance; |
Damien Lespiau | 1b8997b | 2015-06-27 15:33:58 +0100 | [diff] [blame] | 47 | uint64_t *sorted; |
Damien Lespiau | 06f5f70 | 2015-06-25 12:07:56 +0100 | [diff] [blame] | 48 | } igt_stats_t; |
| 49 | |
Damien Lespiau | 66e0bf6 | 2015-06-27 17:49:40 +0100 | [diff] [blame] | 50 | void igt_stats_init(igt_stats_t *stats); |
| 51 | void igt_stats_init_with_size(igt_stats_t *stats, unsigned int capacity); |
Damien Lespiau | 06f5f70 | 2015-06-25 12:07:56 +0100 | [diff] [blame] | 52 | void igt_stats_fini(igt_stats_t *stats); |
Damien Lespiau | da123ad | 2015-06-26 18:04:34 +0100 | [diff] [blame] | 53 | bool igt_stats_is_population(igt_stats_t *stats); |
Damien Lespiau | 3a5cf84 | 2015-06-26 17:02:09 +0100 | [diff] [blame] | 54 | void igt_stats_set_population(igt_stats_t *stats, bool full_population); |
Damien Lespiau | 06f5f70 | 2015-06-25 12:07:56 +0100 | [diff] [blame] | 55 | void igt_stats_push(igt_stats_t *stats, uint64_t value); |
Damien Lespiau | 3839bac | 2015-06-27 15:32:23 +0100 | [diff] [blame] | 56 | void igt_stats_push_array(igt_stats_t *stats, |
| 57 | const uint64_t *values, unsigned int n_values); |
Damien Lespiau | 4a89a84 | 2015-06-27 09:45:42 +0100 | [diff] [blame] | 58 | uint64_t igt_stats_get_min(igt_stats_t *stats); |
| 59 | uint64_t igt_stats_get_max(igt_stats_t *stats); |
Damien Lespiau | 0e4c175 | 2015-06-27 11:12:01 +0100 | [diff] [blame] | 60 | uint64_t igt_stats_get_range(igt_stats_t *stats); |
Damien Lespiau | 1b8997b | 2015-06-27 15:33:58 +0100 | [diff] [blame] | 61 | void igt_stats_get_quartiles(igt_stats_t *stats, |
| 62 | double *q1, double *q2, double *q3); |
Damien Lespiau | fabde38 | 2015-06-27 15:49:26 +0100 | [diff] [blame] | 63 | double igt_stats_get_iqr(igt_stats_t *stats); |
Chris Wilson | 19135a3 | 2015-07-01 13:50:02 +0100 | [diff] [blame] | 64 | double igt_stats_get_iqm(igt_stats_t *stats); |
Damien Lespiau | e55a11d | 2015-06-25 23:44:20 +0100 | [diff] [blame] | 65 | double igt_stats_get_mean(igt_stats_t *stats); |
Chris Wilson | 2d305f6 | 2015-07-01 18:52:46 +0100 | [diff] [blame^] | 66 | double igt_stats_get_trimean(igt_stats_t *stats); |
Damien Lespiau | 1b8997b | 2015-06-27 15:33:58 +0100 | [diff] [blame] | 67 | double igt_stats_get_median(igt_stats_t *stats); |
Damien Lespiau | 05c10f9 | 2015-06-25 23:57:49 +0100 | [diff] [blame] | 68 | double igt_stats_get_variance(igt_stats_t *stats); |
Damien Lespiau | 515cec1 | 2015-06-25 23:59:21 +0100 | [diff] [blame] | 69 | double igt_stats_get_std_deviation(igt_stats_t *stats); |
Damien Lespiau | 087a8d1 | 2015-06-26 14:31:58 +0100 | [diff] [blame] | 70 | |
| 71 | #endif /* __IGT_STATS_H__ */ |