Is this in the global scope? If not, are you just timing the GC ops required to clean up the results of your first step?
— John On Nov 28, 2014, at 3:34 PM, Carlos Baptista <[email protected]> wrote: > In Julia, when running code for a second time, it should complete faster > because on the first run Julia is still compiling stuff. However today I came > across the complete opposite: > > julia> A=rand(5000,5000); > > julia> B=rand(5000,5000); > > julia> for i=1:10 > @time A*B; > end > elapsed time: 5.150001434 seconds (226166468 bytes allocated) > elapsed time: 9.537624646 seconds (200000112 bytes allocated) > elapsed time: 12.596928096 seconds (200000112 bytes allocated) > elapsed time: 14.036605961 seconds (200000112 bytes allocated) > elapsed time: 11.700367259 seconds (200000112 bytes allocated) > elapsed time: 14.919158958 seconds (200000112 bytes allocated) > elapsed time: 10.947261637 seconds (200000112 bytes allocated) > elapsed time: 15.112988735 seconds (200000112 bytes allocated) > elapsed time: 10.867003789 seconds (200000112 bytes allocated) > elapsed time: 14.920659541 seconds (200000112 bytes allocated) > > The first run is actually faster than all the consecutive ones. > > I installed Julia a new yesterday: > > cd ~/Downloads > git clone https://github.com/JuliaLang/julia > sudo mv julia /opt/apps/julia-git > cd /opt/apps/julia-git > make -j 8 > > Can someone explain me why the first run is faster than the rest? >
