diff options
Diffstat (limited to 'tools/perf/bench/mem-memset.c')
-rw-r--r-- | tools/perf/bench/mem-memset.c | 11 |
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 | ||
25 | static const char *length_str = "1MB"; | 25 | static const char *length_str = "1MB"; |
26 | static const char *routine = "default"; | 26 | static const char *routine = "default"; |
27 | static int iterations = 1; | ||
27 | static bool use_clock; | 28 | static bool use_clock; |
28 | static int clock_fd; | 29 | static int clock_fd; |
29 | static bool only_prefault; | 30 | static 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); |