From 12f052b5604fffb852bf66250b89fec56641733c Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 1 Aug 2016 12:58:13 +0100 Subject: igt/gem_mmap_gtt/wc: Reduce test runtime Add a new iterator macro to run for a specified number of milliseconds. Signed-off-by: Chris Wilson --- lib/igt_aux.h | 13 +++++++++++++ tests/gem_mmap_gtt.c | 16 ++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 5627cb04..7f5a7cfd 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -85,6 +85,19 @@ bool __igt_sigiter_continue(struct __igt_sigiter *iter, bool interrupt); #define igt_until_timeout(timeout) \ for (struct timespec t__={}; igt_seconds_elapsed(&t__) < (timeout); ) +/** + * igt_for_milliseconds: + * @time: how long to run the loop in milliseconds + * + * Convenience macro loop to run the provided code block in a loop until the + * target interval has expired. Of course when an individual execution takes + * too long, the actual execution time could be a lot longer. + * + * The code block will be executed at least once. + */ +#define igt_for_milliseconds(t) \ + for (struct timespec t__={}; igt_nsec_elapsed(&t__)>>20 < (t); ) + void igt_exchange_int(void *array, unsigned i, unsigned j); void igt_permute_array(void *array, unsigned size, void (*exchange_func)(void *array, diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c index ef41bcc0..60034df3 100644 --- a/tests/gem_mmap_gtt.c +++ b/tests/gem_mmap_gtt.c @@ -248,26 +248,26 @@ test_wc(int fd) gem_close(fd, handle); gtt_reads = 0; - igt_until_timeout(1) { + igt_for_milliseconds(200) { memcpy(cpu, gtt, 4096); gtt_reads++; } - igt_debug("%lu GTT reads in 1s\n", gtt_reads); + igt_debug("%lu GTT reads in 200us\n", gtt_reads); gtt_writes = 0; - igt_until_timeout(1) { + igt_for_milliseconds(200) { memcpy(gtt, cpu, 4096); gtt_writes++; } - igt_debug("%lu GTT writes in 1s\n", gtt_writes); + igt_debug("%lu GTT writes in 200us\n", gtt_writes); if (igt_setup_clflush()) { cpu_writes = 0; - igt_until_timeout(1) { + igt_for_milliseconds(200) { igt_clflush_range(cpu, 4096); cpu_writes++; } - igt_debug("%lu CPU writes in 1s\n", cpu_writes); + igt_debug("%lu CPU writes in 200us\n", cpu_writes); } else cpu_writes = gtt_writes; @@ -276,11 +276,11 @@ test_wc(int fd) igt_assert_f(gtt_writes > 2*gtt_reads, "Write-Combined writes are expected to be much faster than reads: read=%.2fMiB/s, write=%.2fMiB/s\n", - gtt_reads/256., gtt_writes/256.); + 5*gtt_reads/256., 5*gtt_writes/256.); igt_assert_f(gtt_writes > cpu_writes/2, "Write-Combined writes are expected to be roughly equivalent to WB writes: WC (gtt)=%.2fMiB/s, WB (cpu)=%.2fMiB/s\n", - gtt_writes/256., cpu_writes/256.); + 5*gtt_writes/256., 5*cpu_writes/256.); } static void -- cgit v1.2.3