@@ -133,6 +133,28 @@ void igt_stats_init_with_size(igt_stats_t *stats, unsigned int capacity)
stats->max = 0;
}
+/**
+ * igt_stats_init_from_array:
+ * @stats: An #igt_stats_t instance
+ * @array: (array length=n): Array of uint64_t
+ * @n: Length of @array
+ *
+ * Short hand for:
+ * |[
+ * static const uint64_t s[] = { 10, 12, 14, 16, 87, 53, 90, 72 };
+ * igt_stats_t stats;
+ *
+ * igt_stats_init(&stats);
+ * igt_stats_push_array(&stats, s, ARRAY_SIZE(s));
+ * ]|
+ */
+void igt_stats_init_from_array(igt_stats_t *stats,
+ const uint64_t *array, unsigned int n)
+{
+ igt_stats_init(stats);
+ igt_stats_push_array(stats, array, n);
+}
+
/* https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform */
static double rand_normal(double mean, double stddev)
{
@@ -49,6 +49,8 @@ typedef struct {
void igt_stats_init(igt_stats_t *stats);
void igt_stats_init_with_size(igt_stats_t *stats, unsigned int capacity);
+void igt_stats_init_from_array(igt_stats_t *stats,
+ const uint64_t *array, unsigned int n);
void igt_stats_init_normal(igt_stats_t *stats,
double mean, double std_deviation,
unsigned int n_values);
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com> --- lib/igt_stats.c | 22 ++++++++++++++++++++++ lib/igt_stats.h | 2 ++ 2 files changed, 24 insertions(+)