aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/bench/mem-memcpy.c
diff options
context:
space:
mode:
authorJan Beulich <JBeulich@suse.com>2012-01-18 08:29:59 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-01-24 17:26:10 -0500
commite3e877e79b7c6a322f9f628e87052c13581238cc (patch)
tree0f68ae300a31a0124552ce6eb6a511aea19d10b5 /tools/perf/bench/mem-memcpy.c
parentbe3de80dc2e671d9ee15e69fe9cd84d2b71e2225 (diff)
perf bench: Allow passing an iteration count to "bench mem mem{cpy,set}"
"perf stat ... perf bench mem mem..." is pretty meaningless when using small block sizes (as the overhead of the invocation of each test run basically hides the actual test result in the noise). Repeating the actually interesting function's invocation a number of times allows the results to become meaningful. Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/4F16D767020000780006D738@nat28.tlf.novell.com Signed-off-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/bench/mem-memcpy.c')
-rw-r--r--tools/perf/bench/mem-memcpy.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/perf/bench/mem-memcpy.c b/tools/perf/bench/mem-memcpy.c
index db82021f4b91..6ad2b1c6b27b 100644
--- a/tools/perf/bench/mem-memcpy.c
+++ b/tools/perf/bench/mem-memcpy.c
@@ -24,6 +24,7 @@
24 24
25static const char *length_str = "1MB"; 25static const char *length_str = "1MB";
26static const char *routine = "default"; 26static const char *routine = "default";
27static int iterations = 1;
27static bool use_clock; 28static bool use_clock;
28static int clock_fd; 29static int clock_fd;
29static bool only_prefault; 30static bool only_prefault;
@@ -35,6 +36,8 @@ static const struct option options[] = {
35 "available unit: B, MB, GB (upper and lower)"), 36 "available unit: B, MB, GB (upper and lower)"),
36 OPT_STRING('r', "routine", &routine, "default", 37 OPT_STRING('r', "routine", &routine, "default",
37 "Specify routine to copy"), 38 "Specify routine to copy"),
39 OPT_INTEGER('i', "iterations", &iterations,
40 "repeat memcpy() invocation this number of times"),
38 OPT_BOOLEAN('c', "clock", &use_clock, 41 OPT_BOOLEAN('c', "clock", &use_clock,
39 "Use CPU clock for measuring"), 42 "Use CPU clock for measuring"),
40 OPT_BOOLEAN('o', "only-prefault", &only_prefault, 43 OPT_BOOLEAN('o', "only-prefault", &only_prefault,
@@ -121,6 +124,7 @@ static u64 do_memcpy_clock(memcpy_t fn, size_t len, bool prefault)
121{ 124{
122 u64 clock_start = 0ULL, clock_end = 0ULL; 125 u64 clock_start = 0ULL, clock_end = 0ULL;
123 void *src = NULL, *dst = NULL; 126 void *src = NULL, *dst = NULL;
127 int i;
124 128
125 alloc_mem(&src, &dst, len); 129 alloc_mem(&src, &dst, len);
126 130
@@ -128,7 +132,8 @@ static u64 do_memcpy_clock(memcpy_t fn, size_t len, bool prefault)
128 fn(dst, src, len); 132 fn(dst, src, len);
129 133
130 clock_start = get_clock(); 134 clock_start = get_clock();
131 fn(dst, src, len); 135 for (i = 0; i < iterations; ++i)
136 fn(dst, src, len);
132 clock_end = get_clock(); 137 clock_end = get_clock();
133 138
134 free(src); 139 free(src);
@@ -140,6 +145,7 @@ static double do_memcpy_gettimeofday(memcpy_t fn, size_t len, bool prefault)
140{ 145{
141 struct timeval tv_start, tv_end, tv_diff; 146 struct timeval tv_start, tv_end, tv_diff;
142 void *src = NULL, *dst = NULL; 147 void *src = NULL, *dst = NULL;
148 int i;
143 149
144 alloc_mem(&src, &dst, len); 150 alloc_mem(&src, &dst, len);
145 151
@@ -147,7 +153,8 @@ static double do_memcpy_gettimeofday(memcpy_t fn, size_t len, bool prefault)
147 fn(dst, src, len); 153 fn(dst, src, len);
148 154
149 BUG_ON(gettimeofday(&tv_start, NULL)); 155 BUG_ON(gettimeofday(&tv_start, NULL));
150 fn(dst, src, len); 156 for (i = 0; i < iterations; ++i)
157 fn(dst, src, len);
151 BUG_ON(gettimeofday(&tv_end, NULL)); 158 BUG_ON(gettimeofday(&tv_end, NULL));
152 159
153 timersub(&tv_end, &tv_start, &tv_diff); 160 timersub(&tv_end, &tv_start, &tv_diff);