Are you sure you're not including compilation in those timings? Since Julia
is JIT-compiled ("just-in-time"), the funcitons aren't compiled until you
use them the first time. Thus, you need to do a warmup call first, that
calls the method with arguments of the same type as those you want to time
the function for.
// T
On Friday, June 27, 2014 12:11:02 PM UTC+2, Florian Oswald wrote:
>
> Hi all,
> I found some strange behaviour when running my code. I open 2 clean julia
> sessions and do the following:
>
>
>
> # session 1
> home = ENV["HOME"]
> cd("$home/git/migration/julia")
>
> include("src/mig.jl")
> p = mig.Param(2)
> m = mig.Model(p)
> @time mig.solve!(m,p)
>
> elapsed time: 9.358865389 seconds (236857932 bytes allocated)
>
> # session 2
> home = ENV["HOME"]
> cd("$home/git/migration/julia")
> include("src/mig.jl")
>
> mig.mywrap()
>
> elapsed time: 18.051932747 seconds (226522796 bytes allocated)
>
> the definition of mywrap is
>
> function mywrap()
> p = mig.Param(2)
> m = mig.Model(p)
> @time mig.solve!(m,p)
> end
>
> I thought this is identical? I looked at the @profile of both sessions,
> and the profile timings of mig.solve! (the main computation function) are
> actually lower in session 2 (inside the wrap) than in session 1. I would
> have expected the reverse?
>
>