diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2015-03-20 22:37:00 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2015-03-26 08:15:19 +0000 |
commit | c666a19e0c16821a1ccd2a2ea7dda549d19c67d1 (patch) | |
tree | d725a997307b4d0070b6a27fdf4e717807021c55 /tests/gem_exec_blt.c | |
parent | cd8d3809a6e49b0bd9da53b17217f99b3c86243a (diff) |
igt/gem_exec_blt: Repeat measurement and average
Through away the unstable outliers for a more consistent measurement.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/gem_exec_blt.c')
-rw-r--r-- | tests/gem_exec_blt.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/tests/gem_exec_blt.c b/tests/gem_exec_blt.c index 1707ae49..372c6e21 100644 --- a/tests/gem_exec_blt.c +++ b/tests/gem_exec_blt.c @@ -189,6 +189,17 @@ static uint32_t dumb_create(int fd) return arg.handle; } +static int dcmp(const void *A, const void *B) +{ + const double *a = A, *b = B; + if (*a < *b) + return -1; + else if (*a > *b) + return 1; + else + return 0; +} + static void run(int object_size, bool dumb) { struct drm_i915_gem_execbuffer2 execbuf; @@ -245,16 +256,26 @@ static void run(int object_size, bool dumb) for (count = 1; count <= 1<<12; count <<= 1) { struct timeval start, end; - - gettimeofday(&start, NULL); - for (int loop = 0; loop < count; loop++) - gem_execbuf(fd, &execbuf); - gem_sync(fd, handle); - gettimeofday(&end, NULL); + const int reps = 9; + double t[reps], sum; + int n; + + for (n = 0; n < reps; n++) { + gettimeofday(&start, NULL); + for (int loop = 0; loop < count; loop++) + gem_execbuf(fd, &execbuf); + gem_sync(fd, handle); + gettimeofday(&end, NULL); + t[n] = elapsed(&start, &end, count); + } + qsort(t, n, sizeof(double), dcmp); + sum = 0; + for (n = 2; n < reps - 2; n++) + sum += t[n]; + sum /= reps - 4; igt_info("Time to blt %d bytes x %6d: %7.3fµs, %s\n", - object_size, count, - elapsed(&start, &end, count), - bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6)); + object_size, count, sum, + bytes_per_sec((char *)buf, object_size/sum*1e6)); fflush(stdout); } gem_close(fd, handle); |