-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
make optimize_ticks faster #83
make optimize_ticks faster #83
Conversation
this thing allocates and poisons the whole function, maybe because it's not clear whether it will return nothing I guess?
This is an MWE: function test_ticks(n, i)
y0 = 10^n
x0 = y0-1
x, y = (x0,y0) .* 10.0^i
ticks = optimize_ticks(x, y)[1]
return ticks
end
test_ticks(1, -9)
#┌ Warning: No strict ticks found
#└ @ PlotUtils ~/.julia/dev/PlotUtils/src/ticks.jl:258
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0] and it seems that the corrections to the algorithm fail whenever [test_ticks(1, i) for i in -9:9]
┌ Warning: No strict ticks found
└ @ PlotUtils ~/.julia/dev/PlotUtils/src/ticks.jl:258
┌ Warning: No strict ticks found
└ @ PlotUtils ~/.julia/dev/PlotUtils/src/ticks.jl:258
┌ Warning: No strict ticks found
└ @ PlotUtils ~/.julia/dev/PlotUtils/src/ticks.jl:258
┌ Warning: No strict ticks found
└ @ PlotUtils ~/.julia/dev/PlotUtils/src/ticks.jl:258
┌ Warning: No strict ticks found
└ @ PlotUtils ~/.julia/dev/PlotUtils/src/ticks.jl:258
19-element Array{Array{Float64,1},1}:
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.0]
[0.0, 0.0, 0.0]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0]
[0.001, 0.001, 0.001]
[0.01, 0.01, 0.01]
[0.09, 0.1, 0.1]
[0.9, 0.95, 1.0]
[9.0, 9.5, 10.0]
[90.0, 95.0, 100.0]
[900.0, 950.0, 1000.0]
[9000.0, 9500.0, 10000.0]
[90000.0, 95000.0, 100000.0]
[900000.0, 950000.0, 1.0e6]
[9.0e6, 9.5e6, 1.0e7]
[9.0e7, 9.5e7, 1.0e8]
[9.0e8, 9.5e8, 1.0e9]
[9.0e9, 9.5e9, 1.0e10] |
By the way, I was thinking if we should remove the last item |
so I did some wizardry with the filtering operation and reduced the number of rounding calls to only those that seemed necessary. With all improvements, benchmarking shows this result for the current version: 399.803 μs (2029 allocations: 97.80 KiB) versus this for the original version on master 4.624 ms (159628 allocations: 3.17 MiB) |
Awesome 💖 Ready to merge? |
I would think so, although I haven't written the tests so I don't know if they leave room for unnoticed errors. |
Let me do some regression tests with MakieGallery, might take an hour or so but if those work I see no reason not to merge this! |
@jkrumbiegel Makie and Plots tests pass...looks good to merge! |
I think I fixed this regression in #89. |
I skipped rounding except at the edges at first because only the edges are looked at in the following code in all cases. The full vector is only used if the values are better candidates than the current ones. I struggled a bit with making the tests work, and when they worked I thought everything was fine. But there is still the option to add rounding back in for the non-edge numbers at the end, that would still be better than doing all numbers always (and the rounding appeared to cause quite a bit of slowdown) |
This still fails a couple of tests, although I'm not sure why 1000 or so tests don't fail and a random looking subset does. Anyway, the changes here make the function about 12 times faster for me, from about 4.2ms to 395µs. Maybe someone else has an idea how to fix the tests.