aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--tools/perf/bench/mem-memcpy.c11
-rw-r--r--tools/perf/bench/mem-memset.c11
2 files changed, 18 insertions, 4 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);
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);