aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/bench/mem-memcpy.c
diff options
context:
space:
mode:
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);