diff options
| author | Rabin Vincent <rabin.vincent@axis.com> | 2014-12-02 10:50:41 -0500 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-12-09 07:14:08 -0500 |
| commit | 1182f883113483cefbc3be0178a2df2dc9ae8b77 (patch) | |
| tree | 5cf56d031e524a814e58f9d2a53233a7842c760a /tools | |
| parent | 5bce1a5772cb52aad7e0466484ba07cfbfec2478 (diff) | |
perf bench: Fix memcpy/memset output
The memcpy and memset benchmarks return bogus results when iterations >
0 because the iterations value is not taken into account when
calculating the final result:
$ perf bench mem memset --only-prefault --length 1GB --iterations 1
# Running 'mem/memset' benchmark:
# Copying 1GB Bytes ...
20.798669 GB/Sec (with prefault)
$ perf bench mem memset --only-prefault --length 1GB --iterations 10
# Running 'mem/memset' benchmark:
# Copying 1GB Bytes ...
2.086576 GB/Sec (with prefault)
$ perf bench mem memset --only-prefault --length 1GB --iterations 100
# Running 'mem/memset' benchmark:
# Copying 1GB Bytes ...
212.840917 MB/Sec (with prefault)
Fix this.
Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Rabin Vincent <rabin@rab.in>
Cc: Rabin Vincent <rabinv@axis.com>
Link: http://lkml.kernel.org/r/1417535441-3965-3-git-send-email-rabin.vincent@axis.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/bench/mem-memcpy.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/tools/perf/bench/mem-memcpy.c b/tools/perf/bench/mem-memcpy.c index e18be70c8a47..6c14afe8c1b1 100644 --- a/tools/perf/bench/mem-memcpy.c +++ b/tools/perf/bench/mem-memcpy.c | |||
| @@ -141,6 +141,7 @@ static int bench_mem_common(int argc, const char **argv, | |||
| 141 | { | 141 | { |
| 142 | int i; | 142 | int i; |
| 143 | size_t len; | 143 | size_t len; |
| 144 | double totallen; | ||
| 144 | double result_bps[2]; | 145 | double result_bps[2]; |
| 145 | u64 result_cycle[2]; | 146 | u64 result_cycle[2]; |
| 146 | 147 | ||
| @@ -156,6 +157,7 @@ static int bench_mem_common(int argc, const char **argv, | |||
| 156 | init_cycle(); | 157 | init_cycle(); |
| 157 | 158 | ||
| 158 | len = (size_t)perf_atoll((char *)length_str); | 159 | len = (size_t)perf_atoll((char *)length_str); |
| 160 | totallen = (double)len * iterations; | ||
| 159 | 161 | ||
| 160 | result_cycle[0] = result_cycle[1] = 0ULL; | 162 | result_cycle[0] = result_cycle[1] = 0ULL; |
| 161 | result_bps[0] = result_bps[1] = 0.0; | 163 | result_bps[0] = result_bps[1] = 0.0; |
| @@ -219,10 +221,10 @@ static int bench_mem_common(int argc, const char **argv, | |||
| 219 | if (use_cycle) { | 221 | if (use_cycle) { |
| 220 | printf(" %14lf Cycle/Byte\n", | 222 | printf(" %14lf Cycle/Byte\n", |
| 221 | (double)result_cycle[0] | 223 | (double)result_cycle[0] |
| 222 | / (double)len); | 224 | / totallen); |
| 223 | printf(" %14lf Cycle/Byte (with prefault)\n", | 225 | printf(" %14lf Cycle/Byte (with prefault)\n", |
| 224 | (double)result_cycle[1] | 226 | (double)result_cycle[1] |
| 225 | / (double)len); | 227 | / totallen); |
| 226 | } else { | 228 | } else { |
| 227 | print_bps(result_bps[0]); | 229 | print_bps(result_bps[0]); |
| 228 | printf("\n"); | 230 | printf("\n"); |
| @@ -233,7 +235,7 @@ static int bench_mem_common(int argc, const char **argv, | |||
| 233 | if (use_cycle) { | 235 | if (use_cycle) { |
| 234 | printf(" %14lf Cycle/Byte", | 236 | printf(" %14lf Cycle/Byte", |
| 235 | (double)result_cycle[pf] | 237 | (double)result_cycle[pf] |
| 236 | / (double)len); | 238 | / totallen); |
| 237 | } else | 239 | } else |
| 238 | print_bps(result_bps[pf]); | 240 | print_bps(result_bps[pf]); |
| 239 | 241 | ||
| @@ -244,8 +246,8 @@ static int bench_mem_common(int argc, const char **argv, | |||
| 244 | if (!only_prefault && !no_prefault) { | 246 | if (!only_prefault && !no_prefault) { |
| 245 | if (use_cycle) { | 247 | if (use_cycle) { |
| 246 | printf("%lf %lf\n", | 248 | printf("%lf %lf\n", |
| 247 | (double)result_cycle[0] / (double)len, | 249 | (double)result_cycle[0] / totallen, |
| 248 | (double)result_cycle[1] / (double)len); | 250 | (double)result_cycle[1] / totallen); |
| 249 | } else { | 251 | } else { |
| 250 | printf("%lf %lf\n", | 252 | printf("%lf %lf\n", |
| 251 | result_bps[0], result_bps[1]); | 253 | result_bps[0], result_bps[1]); |
| @@ -253,7 +255,7 @@ static int bench_mem_common(int argc, const char **argv, | |||
| 253 | } else { | 255 | } else { |
| 254 | if (use_cycle) { | 256 | if (use_cycle) { |
| 255 | printf("%lf\n", (double)result_cycle[pf] | 257 | printf("%lf\n", (double)result_cycle[pf] |
| 256 | / (double)len); | 258 | / totallen); |
| 257 | } else | 259 | } else |
| 258 | printf("%lf\n", result_bps[pf]); | 260 | printf("%lf\n", result_bps[pf]); |
| 259 | } | 261 | } |
| @@ -324,7 +326,7 @@ static double do_memcpy_gettimeofday(const struct routine *r, size_t len, | |||
| 324 | 326 | ||
| 325 | free(src); | 327 | free(src); |
| 326 | free(dst); | 328 | free(dst); |
| 327 | return (double)((double)len / timeval2double(&tv_diff)); | 329 | return (double)(((double)len * iterations) / timeval2double(&tv_diff)); |
| 328 | } | 330 | } |
| 329 | 331 | ||
| 330 | int bench_mem_memcpy(int argc, const char **argv, | 332 | int bench_mem_memcpy(int argc, const char **argv, |
| @@ -389,7 +391,7 @@ static double do_memset_gettimeofday(const struct routine *r, size_t len, | |||
| 389 | timersub(&tv_end, &tv_start, &tv_diff); | 391 | timersub(&tv_end, &tv_start, &tv_diff); |
| 390 | 392 | ||
| 391 | free(dst); | 393 | free(dst); |
| 392 | return (double)((double)len / timeval2double(&tv_diff)); | 394 | return (double)(((double)len * iterations) / timeval2double(&tv_diff)); |
| 393 | } | 395 | } |
| 394 | 396 | ||
| 395 | static const char * const bench_mem_memset_usage[] = { | 397 | static const char * const bench_mem_memset_usage[] = { |
