[My GUI plots from Julia are down to 281.4 ms including startup, with Gaston.jl, but below is on Julia-only packages.]
I actually got a bit over 6 sec. for only @time using SimplePlots
(after precompiling) but that’s more than 3x slower than it needs to be. That is with non-default settings and UnicodePlots alone almost 8x faster (or gnuplot 19x times), and this can be achieved partially with a PR to the package, while --compile=min
can’t currently be added to the package itself, and I really want selective optimization for that too, similar to Jeff’s trick, until then consider:
$ alias julia="~/julia-1.6.0-DEV-8f512f3f6d/bin/julia -O0 --compile=min --startup-file=no"
or similar. The fast startup PR to the package, would work for 1.5 and later, and fastest possible would work for 1.4 too with above settings.
With speed of plot down to 0.77 sec. (for UnicodePlots.jl; and for 0.3 sec Gaston.jl that uses preinstalled gnuplot) with all (startup) overhead, I consider “time-to-first plot” not in important issue. The setting -O1
is almost as fast (or the same, my machine was a bit loaded with 29 GB in use), so in general I would probably recommend that for interactive use.
$ ~/julia-1.6.0-DEV-8f512f3f6d/bin/julia -O0 --compile=min --startup-file=no
julia> @time using SimplePlots
1.858364 seconds (2.79 M allocations: 151.739 MiB, 1.99% gc time)
julia> @time plt = plot([-1, 2, 3, 7], [-1, 2, 9, 4])
0.019696 seconds (9.91 k allocations: 648.372 KiB)
And next plot is also fast at this lowest (undocumented) compile setting:
julia> @time plt = plot([-1, 2, 3, 7], [-1, 2, 9, 4], title = "Example Plot", name = "my line", xlabel = "x", ylabel = "y")
0.088250 seconds (44.32 k allocations: 996.578 KiB)
$ hyperfine 'julia-1.4 -O0 --compile=min --startup-file=no -e "using UnicodePlots; plt = plot([-1, 2, 3, 7], [-1, 2, 9, 4])"'
Benchmark #1: julia-1.4 -O0 --compile=min --startup-file=no -e "using UnicodePlots; plt = plot([-1, 2, 3, 7], [-1, 2, 9, 4])"
Time (mean ± σ): 839.0 ms ± 36.5 ms [User: 1.238 s, System: 0.496 s]
Range (min … max): 773.4 ms … 885.8 ms 10 runs
$ hyperfine 'julia-1.6.0-DEV -O0 --compile=min --startup-file=no -e "using SimplePlots; plt = plot([-1, 2, 3, 7], [-1, 2, 9, 4])"'
Benchmark #1: julia-1.6.0-DEV -O0 --compile=min --startup-file=no -e "using SimplePlots; plt = plot([-1, 2, 3, 7], [-1, 2, 9, 4])"
Time (mean ± σ): 2.145 s ± 0.047 s [User: 2.467 s, System: 0.547 s]
Range (min … max): 2.063 s … 2.228 s 10 runs