@@ -0,0 +1,1729 @@
+%0Apackage net.restlesscoder.sandbox.imagej;%0A%0Aimport net.imglib2.KDTree;%0Aimport net.imglib2.RealPoint;%0A%0Aimport java.util.*;%0Aimport java.util.function.Supplier;%0A%0Apublic class KDTreeBenchmark %7B%0A%0A%09public static void main(final String... args) %7B%0A%09%09final Random r = new Random();%0A%09%09final Map%3CString, Supplier%3CRealPoint%3E%3E approaches = new LinkedHashMap%3C%3E();%0A%09%09approaches.put(%22Random%22, () -%3E new RealPoint( r.nextDouble(), r.nextDouble(), r.nextDouble() ));%0A%09%09approaches.put(%22Constant 1.0%22, () -%3E new RealPoint( r.nextDouble(), r.nextDouble(), 1.0 ));%0A%09%09approaches.put(%22Constant 0.5%22, () -%3E new RealPoint( r.nextDouble(), r.nextDouble(), 0.5 ));%0A%09%09approaches.put(%22Constant 0.0%22, () -%3E new RealPoint( r.nextDouble(), r.nextDouble(), 0.0 ));%0A%09%09approaches.put(%22Perturbed 1.0%22, () -%3E new RealPoint( r.nextDouble(), r.nextDouble(), 1.0 + 1e-7*r.nextDouble() ));%0A%09%09approaches.put(%22Perturbed 0.5%22, () -%3E new RealPoint( r.nextDouble(), r.nextDouble(), 0.5 + 1e-7*r.nextDouble() ));%0A%09%09approaches.put(%22Perturbed 0.0%22, () -%3E new RealPoint( r.nextDouble(), r.nextDouble(), 1e-7*r.nextDouble() ));%0A%09%09approaches.put(%22Perturbed -10.0%22, () -%3E new RealPoint( r.nextDouble(), r.nextDouble(), -10 + 1e-7*r.nextDouble() ));%0A%0A%09%09for (int iter=1; iter%3C=5; iter++) %7B%0A%09%09%09System.out.println(%22Iteration #%22 + iter + %22:%22);%0A%09%09%09for (final String approach : approaches.keySet()) %7B%0A%09%09%09%09final Supplier%3CRealPoint%3E supplier = approaches.get(approach);%0A%09%09%09%09final List%3CRealPoint%3E points = new ArrayList%3C%3E();%0A%09%09%09%09for (int i = 0; i %3C 100000; i++)%0A%09%09%09%09%09points.add(supplier.get());%0A%0A%09%09%09%09long start = System.currentTimeMillis();%0A%09%09%09%09new KDTree%3C%3E(points, points);%0A%09%09%09%09System.out.println(%22--%3E %22 + approach + %22: build tree in %22 + (System.currentTimeMillis() - start));%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Add benchmark of ImgLib2's KDTree