Q:

Long first time to plot with Gadfly

I created simple plotting example with Julia
using Gadfly
draw(SVG("example.svg", 10cm, 10cm),
  plot(x=rand(10), y=rand(10))
)

And ran it as time julia example.jl it took it 27 sec to finish. Is it normal behaviour? Is it possible to speed it up?
Latest Julia 0.5.2 and Pkg.

A:

I'm not an expert so take this with a pinch of salt, but you're draw and SVG functions are compiled the first time they're run, that's why the long running time.
If you call the function again, it takes a lot less time. You're paying a penalty to compile the function calls first, but all later executions are quite quick.
I amended you're script to measure the time spent in different calls:
@time using Gadfly
@time draw(SVG("example.svg", 10cm, 10cm),
  plot(x=rand(10), y=rand(10))
)
@time draw(SVG("example2.svg", 10cm, 10cm),
  plot(x=rand(10), y=rand(10))
)

Running this from the console with julia example.jl gives me the following:
$ julia example.jl
2.728577 seconds (3.32 M allocations: 141.186 MB, 10.29% gc time)
20.434172 seconds (27.48 M allocations: 1.109 GB, 1.95% gc time)
0.023084 seconds (32.59 k allocations: 1.444 MB)

