diff options
author | Rehas Sachdeva <aquannie@gmail.com> | 2017-02-27 07:53:00 -0500 |
---|---|---|
committer | Matthew Wilcox <mawilcox@microsoft.com> | 2017-03-07 13:18:20 -0500 |
commit | 6478581c85cd3091a6188a2433a8093f335f8f2a (patch) | |
tree | a989001c21c3ae769cb77bfd216d7afdbd9d5f22 /tools/testing/radix-tree/benchmark.c | |
parent | 0d4a41c1a0335dc515c6e7fabd447263b57f6457 (diff) |
radix tree test suite: Add performance test for radix_tree_split()
Signed-off-by: Rehas Sachdeva <aquannie@gmail.com>
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Diffstat (limited to 'tools/testing/radix-tree/benchmark.c')
-rw-r--r-- | tools/testing/radix-tree/benchmark.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/testing/radix-tree/benchmark.c b/tools/testing/radix-tree/benchmark.c index 35741b9c2a4a..b03c3f30c740 100644 --- a/tools/testing/radix-tree/benchmark.c +++ b/tools/testing/radix-tree/benchmark.c | |||
@@ -146,6 +146,46 @@ static void benchmark_size(unsigned long size, unsigned long step, int order) | |||
146 | rcu_barrier(); | 146 | rcu_barrier(); |
147 | } | 147 | } |
148 | 148 | ||
149 | static long long __benchmark_split(unsigned long index, | ||
150 | int old_order, int new_order) | ||
151 | { | ||
152 | struct timespec start, finish; | ||
153 | long long nsec; | ||
154 | RADIX_TREE(tree, GFP_ATOMIC); | ||
155 | |||
156 | item_insert_order(&tree, index, old_order); | ||
157 | |||
158 | clock_gettime(CLOCK_MONOTONIC, &start); | ||
159 | radix_tree_split(&tree, index, new_order); | ||
160 | clock_gettime(CLOCK_MONOTONIC, &finish); | ||
161 | nsec = (finish.tv_sec - start.tv_sec) * NSEC_PER_SEC + | ||
162 | (finish.tv_nsec - start.tv_nsec); | ||
163 | |||
164 | item_kill_tree(&tree); | ||
165 | |||
166 | return nsec; | ||
167 | |||
168 | } | ||
169 | |||
170 | static void benchmark_split(unsigned long size, unsigned long step) | ||
171 | { | ||
172 | int i, j, idx; | ||
173 | long long nsec = 0; | ||
174 | |||
175 | |||
176 | for (idx = 0; idx < size; idx += step) { | ||
177 | for (i = 3; i < 11; i++) { | ||
178 | for (j = 0; j < i; j++) { | ||
179 | nsec += __benchmark_split(idx, i, j); | ||
180 | } | ||
181 | } | ||
182 | } | ||
183 | |||
184 | printv(2, "Size %8ld, step %8ld, split time %10lld ns\n", | ||
185 | size, step, nsec); | ||
186 | |||
187 | } | ||
188 | |||
149 | void benchmark(void) | 189 | void benchmark(void) |
150 | { | 190 | { |
151 | unsigned long size[] = {1 << 10, 1 << 20, 0}; | 191 | unsigned long size[] = {1 << 10, 1 << 20, 0}; |
@@ -163,4 +203,8 @@ void benchmark(void) | |||
163 | for (c = 0; size[c]; c++) | 203 | for (c = 0; size[c]; c++) |
164 | for (s = 0; step[s]; s++) | 204 | for (s = 0; step[s]; s++) |
165 | benchmark_size(size[c], step[s] << 9, 9); | 205 | benchmark_size(size[c], step[s] << 9, 9); |
206 | |||
207 | for (c = 0; size[c]; c++) | ||
208 | for (s = 0; step[s]; s++) | ||
209 | benchmark_split(size[c], step[s]); | ||
166 | } | 210 | } |