Cache axis args in a dictionary
These axis arguments can be generated lots of times for large plots. We can save time by caching them in a dictionary. For my large map test plot: ``` Before: 1.075 s (3393429 allocations: 183.49 MiB) After: 959.024 ms (3393294 allocations: 181.64 MiB) - 10% improvement in speed, small decrease in allocations TTFP Before: 7.543192 seconds (26.79 M allocations: 1.544 GiB, 3.89% gc time, 0.06% compilation time) TTFP After: 6.886222 seconds (23.58 M allocations: 1.355 GiB, 3.63% gc time, 0.07% compilation time) - 8% improvement in speed, 12% fewer allocations, 12% lower allocation amount ``` The cost of this is, I think, just 3-4 kb. Is there a function to read out the size in memory of a dictionary? `sizeof` for the dictionary itself just returns 64.
This commit is contained in:
parent
22651e8728
commit
0809c21490
15
src/args.jl
15
src/args.jl
@ -1905,6 +1905,8 @@ function _update_axis(
|
|||||||
_update_axis_links(plt, axis, letter)
|
_update_axis_links(plt, axis, letter)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
axisattrcache = Dict{Symbol, Dict{Symbol, Symbol}}()
|
||||||
|
|
||||||
function _update_axis(
|
function _update_axis(
|
||||||
axis::Axis,
|
axis::Axis,
|
||||||
@ -1922,7 +1924,18 @@ function _update_axis(
|
|||||||
end
|
end
|
||||||
|
|
||||||
# then get those args that were passed with a leading letter: `xlabel = "X"`
|
# then get those args that were passed with a leading letter: `xlabel = "X"`
|
||||||
lk = Symbol(letter, k)
|
lt = if haskey(axisattrcache, letter)
|
||||||
|
axisattrcache[letter]
|
||||||
|
else
|
||||||
|
axisattrcache[letter] = Dict{Symbol, Symbol}()
|
||||||
|
end
|
||||||
|
|
||||||
|
lk = if haskey(lt, k)
|
||||||
|
lt[k]
|
||||||
|
else
|
||||||
|
lt[k] = Symbol(letter, k)
|
||||||
|
end
|
||||||
|
|
||||||
if haskey(plotattributes_in, lk)
|
if haskey(plotattributes_in, lk)
|
||||||
kw[k] = slice_arg(plotattributes_in[lk], subplot_index)
|
kw[k] = slice_arg(plotattributes_in[lk], subplot_index)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user