diff options
Diffstat (limited to 'tools/perf/bench/mem-memcpy.c')
-rw-r--r-- | tools/perf/bench/mem-memcpy.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/perf/bench/mem-memcpy.c b/tools/perf/bench/mem-memcpy.c index db82021f4b91..71557225bf92 100644 --- a/tools/perf/bench/mem-memcpy.c +++ b/tools/perf/bench/mem-memcpy.c | |||
@@ -5,7 +5,6 @@ | |||
5 | * | 5 | * |
6 | * Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> | 6 | * Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> |
7 | */ | 7 | */ |
8 | #include <ctype.h> | ||
9 | 8 | ||
10 | #include "../perf.h" | 9 | #include "../perf.h" |
11 | #include "../util/util.h" | 10 | #include "../util/util.h" |
@@ -24,6 +23,7 @@ | |||
24 | 23 | ||
25 | static const char *length_str = "1MB"; | 24 | static const char *length_str = "1MB"; |
26 | static const char *routine = "default"; | 25 | static const char *routine = "default"; |
26 | static int iterations = 1; | ||
27 | static bool use_clock; | 27 | static bool use_clock; |
28 | static int clock_fd; | 28 | static int clock_fd; |
29 | static bool only_prefault; | 29 | static bool only_prefault; |
@@ -35,6 +35,8 @@ static const struct option options[] = { | |||
35 | "available unit: B, MB, GB (upper and lower)"), | 35 | "available unit: B, MB, GB (upper and lower)"), |
36 | OPT_STRING('r', "routine", &routine, "default", | 36 | OPT_STRING('r', "routine", &routine, "default", |
37 | "Specify routine to copy"), | 37 | "Specify routine to copy"), |
38 | OPT_INTEGER('i', "iterations", &iterations, | ||
39 | "repeat memcpy() invocation this number of times"), | ||
38 | OPT_BOOLEAN('c', "clock", &use_clock, | 40 | OPT_BOOLEAN('c', "clock", &use_clock, |
39 | "Use CPU clock for measuring"), | 41 | "Use CPU clock for measuring"), |
40 | OPT_BOOLEAN('o', "only-prefault", &only_prefault, | 42 | OPT_BOOLEAN('o', "only-prefault", &only_prefault, |
@@ -121,6 +123,7 @@ static u64 do_memcpy_clock(memcpy_t fn, size_t len, bool prefault) | |||
121 | { | 123 | { |
122 | u64 clock_start = 0ULL, clock_end = 0ULL; | 124 | u64 clock_start = 0ULL, clock_end = 0ULL; |
123 | void *src = NULL, *dst = NULL; | 125 | void *src = NULL, *dst = NULL; |
126 | int i; | ||
124 | 127 | ||
125 | alloc_mem(&src, &dst, len); | 128 | alloc_mem(&src, &dst, len); |
126 | 129 | ||
@@ -128,7 +131,8 @@ static u64 do_memcpy_clock(memcpy_t fn, size_t len, bool prefault) | |||
128 | fn(dst, src, len); | 131 | fn(dst, src, len); |
129 | 132 | ||
130 | clock_start = get_clock(); | 133 | clock_start = get_clock(); |
131 | fn(dst, src, len); | 134 | for (i = 0; i < iterations; ++i) |
135 | fn(dst, src, len); | ||
132 | clock_end = get_clock(); | 136 | clock_end = get_clock(); |
133 | 137 | ||
134 | free(src); | 138 | free(src); |
@@ -140,6 +144,7 @@ static double do_memcpy_gettimeofday(memcpy_t fn, size_t len, bool prefault) | |||
140 | { | 144 | { |
141 | struct timeval tv_start, tv_end, tv_diff; | 145 | struct timeval tv_start, tv_end, tv_diff; |
142 | void *src = NULL, *dst = NULL; | 146 | void *src = NULL, *dst = NULL; |
147 | int i; | ||
143 | 148 | ||
144 | alloc_mem(&src, &dst, len); | 149 | alloc_mem(&src, &dst, len); |
145 | 150 | ||
@@ -147,7 +152,8 @@ static double do_memcpy_gettimeofday(memcpy_t fn, size_t len, bool prefault) | |||
147 | fn(dst, src, len); | 152 | fn(dst, src, len); |
148 | 153 | ||
149 | BUG_ON(gettimeofday(&tv_start, NULL)); | 154 | BUG_ON(gettimeofday(&tv_start, NULL)); |
150 | fn(dst, src, len); | 155 | for (i = 0; i < iterations; ++i) |
156 | fn(dst, src, len); | ||
151 | BUG_ON(gettimeofday(&tv_end, NULL)); | 157 | BUG_ON(gettimeofday(&tv_end, NULL)); |
152 | 158 | ||
153 | timersub(&tv_end, &tv_start, &tv_diff); | 159 | timersub(&tv_end, &tv_start, &tv_diff); |