JuliaMath / JuliaMath/Interpolations.jl
Bounds Checking Dramatically Reduces Performance
- Dominant language
- Julia
- Stars
- 575
- Forks
- 117
- PR merge metrics
- No merged PRs in 30d
Description
I have a script which does some interpolations over a 5D grid.
When running the script below normally from the command line, it takes ~25 seconds on my machine, mostly compilation time. However, when I run it with `julia --bounds-check=yes` (or in the test suite, which is how I encountered into this problem), it takes nearly 12 minutes.
For interactive/production usage the package currently works fine, but when using an interpolator in a test, performance drops dramatically. Can anything be done to improve performance when bounds checking is turned on?
Script to demonstrate:
```julia
import Interpolations as ITP
function make_interpolator(preds, data)
itp = ITP.interpolate(data, ITP.BSpline(ITP.Cubic(ITP.Line(ITP.OnGrid()))))
etpf = ITP.extrapolate(itp, ITP.Flat())
return ITP.scale(etpf, preds...)
end
data = [
556349.6008704818 685054.7413928926; 337374.20860475855 917776.3775522095;;; 334561.15326837776 656045.6541346011; 531275.5763673111 956019.3625939675;;;; 503423.6161355341 885549.2837607361; 60388.76774041346 879492.3386633231;;; 603084.6996757543 991251.0585302819; 579549.8986152456 367420.19662000256;;;;;
869553.4452428828 66685.83346470346; 479207.3430831957 114053.8123128425;;; 34064.47078306818 90426.76885625877; 964992.7885397973 580234.4705046738;;;; 417425.5870441628 106769.75855182836; 218856.14729614765 84848.46219219244;;; 382595.28561278287 91699.85134152214; 585552.6744809537 269352.3289748475
]
preds = (0.0:20.0:20.0, 1.3:0.1:1.4, 0.9:0.1:1.0, 1.0:2.0:3.0, 130.0:5.0:135.0)
itp = make_interpolator(preds, data)
itp(0.0, 1.3, 0.9, 1.0, 130.0)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.