Closed peteraisher closed 4 years ago
Oh wow, thats really cool @peteraisher !
Can we do some performance analysis with this? If you run the Unit Tests target of the macos example there are already statistics being assembled, we can compare the results?
@hsnetzer already did a similar graph for his PR here: https://github.com/Bersaelor/KDTree/pull/38#issuecomment-425217070
Thanks!
Can we do some performance analysis with this?
I tweaked the code in KDTree_OSX_ExampleTests.PerformanceTests testPerformanceExample
to build the tree ten times and take the average elapsed time, and got these results:
n.b. I used identical random data ten times, but the data between runs (i.e. for the two different algorithms) was not the same. I guess a rigorous comparison would have used ten different sets of input data but used identical data for both algorithms. I think the general outcome looks promising though.
Thank you, that looks great!
Implement Hoare's partitioning algorithm to replace Lomuto's algorithm, thereby reducing the expected number of calls to
MutableCollection.swapAt(_:_:)
.For random unsorted input data, the expected number of swaps is ~ 3x times lower for Hoare's algorithm.