]> git.baikalelectronics.ru Git - kernel.git/commitdiff
radix tree test suite: Add performance test for radix_tree_split()
authorRehas Sachdeva <aquannie@gmail.com>
Mon, 27 Feb 2017 12:53:00 +0000 (07:53 -0500)
committerMatthew Wilcox <mawilcox@microsoft.com>
Tue, 7 Mar 2017 18:18:20 +0000 (13:18 -0500)
Signed-off-by: Rehas Sachdeva <aquannie@gmail.com>
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
tools/testing/radix-tree/benchmark.c

index 35741b9c2a4a1e321ea41f79698b04259d9e04a9..b03c3f30c740c9d24208920acc3d52dcde3402db 100644 (file)
@@ -146,6 +146,46 @@ static void benchmark_size(unsigned long size, unsigned long step, int order)
        rcu_barrier();
 }
 
+static long long  __benchmark_split(unsigned long index,
+                                   int old_order, int new_order)
+{
+       struct timespec start, finish;
+       long long nsec;
+       RADIX_TREE(tree, GFP_ATOMIC);
+
+       item_insert_order(&tree, index, old_order);
+
+       clock_gettime(CLOCK_MONOTONIC, &start);
+       radix_tree_split(&tree, index, new_order);
+       clock_gettime(CLOCK_MONOTONIC, &finish);
+       nsec = (finish.tv_sec - start.tv_sec) * NSEC_PER_SEC +
+              (finish.tv_nsec - start.tv_nsec);
+
+       item_kill_tree(&tree);
+
+       return nsec;
+
+}
+
+static void benchmark_split(unsigned long size, unsigned long step)
+{
+       int i, j, idx;
+       long long nsec = 0;
+
+
+       for (idx = 0; idx < size; idx += step) {
+               for (i = 3; i < 11; i++) {
+                       for (j = 0; j < i; j++) {
+                               nsec += __benchmark_split(idx, i, j);
+                       }
+               }
+       }
+
+       printv(2, "Size %8ld, step %8ld, split time %10lld ns\n",
+                       size, step, nsec);
+
+}
+
 void benchmark(void)
 {
        unsigned long size[] = {1 << 10, 1 << 20, 0};
@@ -163,4 +203,8 @@ void benchmark(void)
        for (c = 0; size[c]; c++)
                for (s = 0; step[s]; s++)
                        benchmark_size(size[c], step[s] << 9, 9);
+
+       for (c = 0; size[c]; c++)
+               for (s = 0; step[s]; s++)
+                       benchmark_split(size[c], step[s]);
 }