aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/bench/mem-memset.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-memset.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-memset.c')
-rw-r--r--tools/perf/bench/mem-memset.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/perf/bench/mem-memset.c b/tools/perf/bench/mem-memset.c
index 9c0c6f0cba9b..59d4933eff44 100644
--- a/tools/perf/bench/mem-memset.c
+++ b/tools/perf/bench/mem-memset.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 memset() 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,
@@ -117,6 +120,7 @@ static u64 do_memset_clock(memset_t fn, size_t len, bool prefault)
117{ 120{
118 u64 clock_start = 0ULL, clock_end = 0ULL; 121 u64 clock_start = 0ULL, clock_end = 0ULL;
119 void *dst = NULL; 122 void *dst = NULL;
123 int i;
120 124
121 alloc_mem(&dst, len); 125 alloc_mem(&dst, len);
122 126
@@ -124,7 +128,8 @@ static u64 do_memset_clock(memset_t fn, size_t len, bool prefault)
124 fn(dst, -1, len); 128 fn(dst, -1, len);
125 129
126 clock_start = get_clock(); 130 clock_start = get_clock();
127 fn(dst, 0, len); 131 for (i = 0; i < iterations; ++i)
132 fn(dst, i, len);
128 clock_end = get_clock(); 133 clock_end = get_clock();
129 134
130 free(dst); 135 free(dst);
@@ -135,6 +140,7 @@ static double do_memset_gettimeofday(memset_t fn, size_t len, bool prefault)
135{ 140{
136 struct timeval tv_start, tv_end, tv_diff; 141 struct timeval tv_start, tv_end, tv_diff;
137 void *dst = NULL; 142 void *dst = NULL;
143 int i;
138 144
139 alloc_mem(&dst, len); 145 alloc_mem(&dst, len);
140 146
@@ -142,7 +148,8 @@ static double do_memset_gettimeofday(memset_t fn, size_t len, bool prefault)
142 fn(dst, -1, len); 148 fn(dst, -1, len);
143 149
144 BUG_ON(gettimeofday(&tv_start, NULL)); 150 BUG_ON(gettimeofday(&tv_start, NULL));
145 fn(dst, 0, len); 151 for (i = 0; i < iterations; ++i)
152 fn(dst, i, len);
146 BUG_ON(gettimeofday(&tv_end, NULL)); 153 BUG_ON(gettimeofday(&tv_end, NULL));
147 154
148 timersub(&tv_end, &tv_start, &tv_diff); 155 timersub(&tv_end, &tv_start, &tv_diff);