Reputation: 15336
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.
Upvotes: 0
Views: 522
Reputation: 7893
I have tried to do the same example with GR.jl
as suggested by @daycaster and got 3.3 seconds on one laptop with Windows 10 64 bits:
PS C:\Users\dell\plot_example> cat plot.jl
using GR
plot(rand(10), rand(10), size = (500, 500))
savefig("plot.svg")
PS C:\Users\dell\plot_example> Measure-Command {julia plot.jl}
Days : 0
Hours : 0
Minutes : 0
Seconds : 3
Milliseconds : 382
Ticks : 33822083
TotalDays : 3.91459293981481E-05
TotalHours : 0.000939502305555556
TotalMinutes : 0.0563701383333333
TotalSeconds : 3.3822083
TotalMilliseconds : 3382.2083
Version and CPU:
PS C:\Users\dell\plot_example> julia -q
julia> VERSION
v"0.5.1"
julia> Sys.cpu_info()[]
Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz:
speed user nice sys idle irq ticks
2304 MHz 18360406 0 10161406 218911218 2123421 ticks
Example plot:
Upvotes: 2
Reputation: 5063
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)
Upvotes: 5