I’m building kdtree library and my build and query times slow down when I introduce generics over several float types
Looking at just the tree build time using into_tree for now because it introduces the least amount of changes, I simply changed CP32 to some generic T: PartialOrd and the code runs 6% slower.
These are the build/build and build/build_f32 benchmarks run with RUSTFLAGS="-C target-cpu=native" cargo bench
(this compares generic vs main, i.e. main is 6% faster so generic is ≈6% slower)
build/build time: [3.0397 ms 3.0498 ms 3.0706 ms]
change: [-7.4159% -6.8037% -6.1435%] (p = 0.00 < 0.05)
Performance has improved.
build/build_f32 time: [1.8228 ms 1.8253 ms 1.8280 ms]
change: [-2.7180% -2.2652% -1.8788%] (p = 0.00 < 0.05)
Performance has improved.
The query code, which adds generics over the input types for queries but is more complicated to review and does add a few other changes adds 20-30% more time.
https://github.com/cavemanloverboy/bosque/compare/generic?expand=1