Optimize volume_montecarlo performance
Improved array operations by pre-allocating arrays and reducing concatenations
Standard information about the request
A standard efficiency upgrade for the volume_montecarlo function. It doesn't change the output of the function at all.
This change affects: the offline search, PyGRB This change: follows style guidelines (See e.g. PEP8), has been proposed using the contribution guidelines
Motivation
I saw the function was using a lot of concat calls which could be reduced, as it can be a substantial performance bottleneck.
Contents
All-round performance optimizations to the function were made, primarily improving the efficiency of the array operations. The performance improvements made were quite substantial, as can be seen from the testing below.
Testing performed
| Size | Original (s) | Optimized (s) | Speedup |
|---|---|---|---|
| 100 | 0.000651 | 0.000357 | 1.82x |
| 1000 | 0.001938 | 0.000629 | 3.08x |
| 10000 | 0.023510 | 0.007141 | 3.29x |
| 100000 | 0.323696 | 0.057062 | 5.67x |
- [x] The author of this pull request confirms they will adhere to the code of conduct
This does not affect PyGRB, as far as I know.
What specific example function call was made to obtain the advertised speedups?