I have created a simple function in a module file “test.jl”
module test
export test0
function test0( s::Float64 )::Float64
return s*100
end
end
Then I create another script main.jl to run this function
using BenchmarkTools
using InteractiveUtils
push!(LOAD_PATH, ".")
using test
@time test0( rand() )
@time test0( rand() )
@time test0( rand() )
@time test0( rand() )
I am confused why the first run costs much more time.
I know I should use @benchmark or @btime to check the average time cost, but in practice most of the functions are called only once and the time has been cost.
And it seems test0 function in test.jl has been compiled into test.ji. What was the first call doing?
Also is there some way to save the module loading time?