I am trying to find a way to finally deploy the program I have written in Julia. And having a binary seems to be the way to go, since I don’t expect the user to have Julia installed.
So I use PackageCompiler.jl. I compiled the hello.jl example from the package example directory. The code looks like this:
module Hello
using UnicodePlots
Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
println("hello, world")
@show sin(0.0)
println(lineplot(1:100, sin.(range(0, stop=2π, length=100))))
return 0
end
end
The compilation took almost 2 minutes.
real 1m50.334s
user 1m54.636s
sys 0m2.404s
Well, if the binary produced runs as fast as in REPL, I can tolerate it.
But I timed the binary, it took
real 0m0.650s
user 0m0.663s
sys 0m0.163s
I time the same function in REPL, with slight modification:
julia> function main()
println("hello, world")
@show sin(0.0)
println(lineplot(1:100, sin.(range(0, stop=2π, length=100))))
end
main (generic function with 1 method)
It took only 0.02 seconds
Julia> @time main()
0.025196 seconds (12.68 k allocations: 528.891 KiB)
My final question, why is the binary slower than function in REPL? Is there any way to get the same speed as running the function in REPL?
Thank you in advance!