diff options
author | Rehas Sachdeva <aquannie@gmail.com> | 2017-02-27 08:11:00 -0500 |
---|---|---|
committer | Matthew Wilcox <mawilcox@microsoft.com> | 2017-03-07 13:18:21 -0500 |
commit | 54f4d3341c8fe31e20915e2c1fb322ff8a069832 (patch) | |
tree | 1e98157d8a8be976676d5635448addd822539540 /tools/testing/radix-tree/benchmark.c | |
parent | 6478581c85cd3091a6188a2433a8093f335f8f2a (diff) |
radix tree test suite: Add performance test for radix_tree_join()
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 | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tools/testing/radix-tree/benchmark.c b/tools/testing/radix-tree/benchmark.c index b03c3f30c740..99c40f3ed133 100644 --- a/tools/testing/radix-tree/benchmark.c +++ b/tools/testing/radix-tree/benchmark.c | |||
@@ -186,6 +186,50 @@ static void benchmark_split(unsigned long size, unsigned long step) | |||
186 | 186 | ||
187 | } | 187 | } |
188 | 188 | ||
189 | static long long __benchmark_join(unsigned long index, | ||
190 | unsigned order1, unsigned order2) | ||
191 | { | ||
192 | unsigned long loc; | ||
193 | struct timespec start, finish; | ||
194 | long long nsec; | ||
195 | void *item, *item2 = item_create(index + 1, order1); | ||
196 | RADIX_TREE(tree, GFP_KERNEL); | ||
197 | |||
198 | item_insert_order(&tree, index, order2); | ||
199 | item = radix_tree_lookup(&tree, index); | ||
200 | |||
201 | clock_gettime(CLOCK_MONOTONIC, &start); | ||
202 | radix_tree_join(&tree, index + 1, order1, item2); | ||
203 | clock_gettime(CLOCK_MONOTONIC, &finish); | ||
204 | nsec = (finish.tv_sec - start.tv_sec) * NSEC_PER_SEC + | ||
205 | (finish.tv_nsec - start.tv_nsec); | ||
206 | |||
207 | loc = find_item(&tree, item); | ||
208 | if (loc == -1) | ||
209 | free(item); | ||
210 | |||
211 | item_kill_tree(&tree); | ||
212 | |||
213 | return nsec; | ||
214 | } | ||
215 | |||
216 | static void benchmark_join(unsigned long step) | ||
217 | { | ||
218 | int i, j, idx; | ||
219 | long long nsec = 0; | ||
220 | |||
221 | for (idx = 0; idx < 1 << 10; idx += step) { | ||
222 | for (i = 1; i < 15; i++) { | ||
223 | for (j = 0; j < i; j++) { | ||
224 | nsec += __benchmark_join(idx, i, j); | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | |||
229 | printv(2, "Size %8d, step %8ld, join time %10lld ns\n", | ||
230 | 1 << 10, step, nsec); | ||
231 | } | ||
232 | |||
189 | void benchmark(void) | 233 | void benchmark(void) |
190 | { | 234 | { |
191 | unsigned long size[] = {1 << 10, 1 << 20, 0}; | 235 | unsigned long size[] = {1 << 10, 1 << 20, 0}; |
@@ -207,4 +251,7 @@ void benchmark(void) | |||
207 | for (c = 0; size[c]; c++) | 251 | for (c = 0; size[c]; c++) |
208 | for (s = 0; step[s]; s++) | 252 | for (s = 0; step[s]; s++) |
209 | benchmark_split(size[c], step[s]); | 253 | benchmark_split(size[c], step[s]); |
254 | |||
255 | for (s = 0; step[s]; s++) | ||
256 | benchmark_join(step[s]); | ||
210 | } | 257 | } |