Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Rehas Sachdeva and committed by
Matthew Wilcox
54f4d334 6478581c

+47
+47
tools/testing/radix-tree/benchmark.c
··· 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 233 void benchmark(void) 190 234 { 191 235 unsigned long size[] = {1 << 10, 1 << 20, 0}; ··· 251 207 for (c = 0; size[c]; c++) 252 208 for (s = 0; step[s]; s++) 253 209 benchmark_split(size[c], step[s]); 210 + 211 + for (s = 0; step[s]; s++) 212 + benchmark_join(step[s]); 254 213 }