-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance differences with Interpolations.jl on ranges #43
Comments
I suspect most of this might be because the linear and cubic splines are still using |
I just ran the same code on with DataInterpolations v3.3.1 and Interpolations v0.13.1 and got these timings: Julia v1.6.0-rc2: cubic spline with DataInterpolations
38.427 μs (1 allocation: 896 bytes)
408.335 ns (0 allocations: 0 bytes)
cubic spline with Interpolations
1.156 μs (1 allocation: 896 bytes)
36.580 ns (0 allocations: 0 bytes)
linear with DataInterpolations
5.522 μs (1 allocation: 896 bytes)
53.387 ns (0 allocations: 0 bytes)
linear with Interpolations
423.192 ns (1 allocation: 896 bytes)
24.242 ns (0 allocations: 0 bytes) Julia v1.5.4: cubic spline with DataInterpolations
40.274 μs (1 allocation: 896 bytes)
417.327 ns (0 allocations: 0 bytes)
cubic spline with Interpolations
1.208 μs (1 allocation: 896 bytes)
37.548 ns (0 allocations: 0 bytes)
linear with DataInterpolations
4.624 μs (1 allocation: 896 bytes)
43.708 ns (0 allocations: 0 bytes)
linear with Interpolations
507.788 ns (1 allocation: 896 bytes)
26.072 ns (0 allocations: 0 bytes) It seems the difference is a bit larger (did Interpolation.jl improve since last post?). If I'm not bringing anything useful here I apologize for the noise but I just thought I should share it since I ran it, just in case it's useful. |
It would be interesting to see how we got such a big regression. |
Current state: julia> println("cubic spline with DataInterpolations")
cubic spline with DataInterpolations
julia> interp = DataInterpolations.CubicSpline(u,t);
julia> @btime $interp($x);
2.767 μs (1 allocation: 896 bytes)
julia> @btime $interp(0.5);
32.797 ns (0 allocations: 0 bytes)
julia> println("cubic spline with Interpolations")
cubic spline with Interpolations
julia> interp2 = Interpolations.CubicSplineInterpolation(t, u);
julia> @btime $interp2.($x);
550.802 ns (1 allocation: 896 bytes)
julia> @btime $interp2(0.5);
21.643 ns (0 allocations: 0 bytes)
julia>
julia> println("linear with DataInterpolations")
linear with DataInterpolations
julia> interplin = DataInterpolations.LinearInterpolation(u,t);
julia> @btime $interplin($x);
2.511 μs (1 allocation: 896 bytes)
julia> @btime $interplin(0.5);
31.325 ns (0 allocations: 0 bytes)
julia> println("linear with Interpolations")
linear with Interpolations
julia> interplin2 = Interpolations.LinearInterpolation(t, u);
julia> @btime $interplin2.($x);
255.398 ns (1 allocation: 896 bytes)
julia> @btime $interplin2(0.5);
16.100 ns (0 allocations: 0 bytes) I changed the title because it seems to be about a missing specialization. If I do:
but:
So what's really going on here is that Interpolations.jl only supports ranges, and it's specializing on the fact that ranges have equally spaced values so it improves performance in that case. Meanwhile, DataInterpolations.jl supports arbitrary spacing and does not specialize here. @sathvikbhagavan maybe it would be good to look into specializing some of the common formulas like linear interpolation based on ranges. |
Using the following code
I get the output
Lots of room for mistakes in the crude benchmarking and eliminated code, but worth taking a look at. For versions
The text was updated successfully, but these errors were encountered: