I am trying to reduce the load time of my project. What I found, using:
using Timers; tic()
using MAT, PyPlot
function read_lookup(varname="Tables")
file = matopen(joinpath("data", "TablesCpCtCq.mat"))
res = read(file, varname)
close(file)
res
end
start=toc()
tables=read_lookup()
stop=toc()
println(stop-start)
# Startup: 0.8s
# read_lookup: 1.2s
# without PyPlot
# Startup: 0.0s
# read_lookup: 0.4s
I am just looking at the initial compilation time and I am using a custom system image.
If I do not load PyPlot, the first call to read_lookup needs 0.4s, if I have using PyPlot
in the code the same call needs 1.2s.
Any idea?
mkitti
2
It’s probably method invalidation:
See the following if you want to analyze further:
https://timholy.github.io/SnoopCompile.jl/dev/snoopr/
Better example, includes a function to create the test file:
using Timers; tic()
using MAT#, PyPlot
function read_lookup(varname="varname")
file = matopen("matfile.mat")
res = read(file, varname)
close(file)
res
end
function create_mat_file()
variable=zeros(40,40)
file = matopen("matfile.mat", "w")
write(file, "varname", variable)
close(file)
end
start=toc()
tables=read_lookup()
stop=toc()
println(stop-start)
# Startup: 0.83s
# load_mat: 0.73s
# without PyPlot
# Startup: 0.0s
# load_mat: 0.4s