In my application, I am calculating atomic distances, which must be precise. As far as I am aware, the only precise way to do this is by using the square root function. However, using the square root function has created a bottleneck in my application.
The data processed by the application will be reprocessed several times in the future, so caching the result of sqrt() may increase performance after the first run, but only if the correct efficient collection type is used. There is likely to be around 20,000 sqrt results stored in the collection.
I am considering Dictionary which would store the query number 'd' and the sqrt() result. Is this the best solution, would a different collection be better, or should I implement a collection especially for the task?
Seeing as Dictionary
is O(1) it was the best possibility for caching the sqrt()
results.