[Intel-gfx] [PATCH i-g-t 02/16] stats: Add an igt_stats_init_from_array() variant

Damien Lespiau damien.lespiau at intel.com
Mon Jul 6 05:35:30 PDT 2015


Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 lib/igt_stats.c | 22 ++++++++++++++++++++++
 lib/igt_stats.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/lib/igt_stats.c b/lib/igt_stats.c
index 37fcc23..1103a7b 100644
--- a/lib/igt_stats.c
+++ b/lib/igt_stats.c
@@ -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)
 {
diff --git a/lib/igt_stats.h b/lib/igt_stats.h
index e1757b7..d6eb48f 100644
--- a/lib/igt_stats.h
+++ b/lib/igt_stats.h
@@ -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);
-- 
2.1.0



More information about the Intel-gfx mailing list