diff mbox series

i915/gem_flink_race.c: Use statistics over list of numbers

Message ID 20201120022157.23880-1-steven.t.hampson@intel.com (mailing list archive)
State New, archived
Headers show
Series i915/gem_flink_race.c: Use statistics over list of numbers | expand

Commit Message

Steve Hampson Nov. 20, 2020, 2:21 a.m. UTC
Print median and range instead of a list of numbers in function test_flink_name.

Signed-off-by: Steve Hampson <steven.t.hampson@intel.com>
---
 tests/i915/gem_flink_race.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/tests/i915/gem_flink_race.c b/tests/i915/gem_flink_race.c
index cf07aedf1..04b7bd42c 100644
--- a/tests/i915/gem_flink_race.c
+++ b/tests/i915/gem_flink_race.c
@@ -83,14 +83,14 @@  static void test_flink_name(int timeout)
 	struct flink_name *threads;
 	int r, i, num_threads;
 	unsigned long count;
-	char buf[512];
 	void *status;
-	int len;
+	igt_stats_t s;
 
 	num_threads = sysconf(_SC_NPROCESSORS_ONLN) - 1;
 	if (!num_threads)
 		num_threads = 1;
 
+	igt_stats_init_with_size(&s, num_threads);
 	threads = calloc(num_threads, sizeof(*threads));
 
 	fd = drm_open_driver(DRIVER_INTEL);
@@ -114,19 +114,15 @@  static void test_flink_name(int timeout)
 
 	pls_die = 1;
 
-	len = snprintf(buf, sizeof(buf), "Completed %lu cycles with [", count);
+	igt_info("Completed %lu cycles\n", count);
 	for (i = 0;  i < num_threads; i++) {
 		pthread_join(threads[i].thread, &status);
 		igt_assert(status == 0);
-		/* Below, constant 11 is 8 digit number, comma, space and null byte */
-		if ((len + 11 + 1) < sizeof(buf))
-			len += snprintf(buf + len, sizeof(buf) - len, "%8lu, ", threads[i].count);
+		igt_stats_push(&s, threads[i].count);
 	}
-	/* Below, constant 9 is 7 bytes for terminating string plus \n and null byte */
-	if (len + 9 < sizeof(buf))
-		snprintf(buf + len - 2, sizeof(buf) - len + 2, "] races");
-	igt_info("%s\n", buf);
-
+	igt_info("Threads %d\n", num_threads);
+	igt_info("Range   %ld\n", igt_stats_get_range(&s));
+	igt_info("Median  %g\n", igt_stats_get_median(&s));
 	close(fd);
 }