From 397cd4acd1c7789482eadb5cf24e667a9684d1fa Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 13 Sep 2012 15:05:34 +0100 Subject: [PATCH] gem_gtt_speed: Add a test that caches the mmapping across iterations Repeat the memset streaming performance test on the same mapping so that we can factor out the overhead of establishing the GTT/CPU mmaps. Signed-off-by: Chris Wilson --- tests/gem_gtt_speed.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/gem_gtt_speed.c b/tests/gem_gtt_speed.c index 824eca3e..f0fb901b 100644 --- a/tests/gem_gtt_speed.c +++ b/tests/gem_gtt_speed.c @@ -143,6 +143,15 @@ int main(int argc, char **argv) gettimeofday(&end, NULL); printf("Time to clear %dk through a CPU map: %7.3fµs\n", size/1024, elapsed(&start, &end, loop)); + + gettimeofday(&start, NULL); + base = gem_mmap__cpu(fd, handle, size, PROT_READ | PROT_WRITE); + for (loop = 0; loop < 1000; loop++) + memset(base, 0, size); + munmap(base, size); + gettimeofday(&end, NULL); + printf("Time to clear %dk through a cached CPU map: %7.3fµs\n", + size/1024, elapsed(&start, &end, loop)); } /* CPU pwrite */ @@ -221,6 +230,15 @@ int main(int argc, char **argv) printf("Time to clear %dk through a GTT map: %7.3fµs\n", size/1024, elapsed(&start, &end, loop)); + gettimeofday(&start, NULL);{ + uint32_t *base = gem_mmap(fd, handle, size, PROT_READ | PROT_WRITE); + for (loop = 0; loop < 1000; loop++) + memset(base, 0, size); + munmap(base, size); + } gettimeofday(&end, NULL); + printf("Time to clear %dk through a cached GTT map: %7.3fµs\n", + size/1024, elapsed(&start, &end, loop)); + /* mmap read */ gettimeofday(&start, NULL); for (loop = 0; loop < 1000; loop++) {