Ay, how many times I've done it! Still forget about global variables!

OK, I see now about `.+` and friends.

Thanks!

On Friday, October 21, 2016 at 3:59:59 AM UTC+2, Steven G. Johnson wrote:
>
> Putting things into a function to avoid benchmarking in global scope:
>  
>
> foo!(x,y) = x .= cos.(sin.(y))
>
> y = rand(1000); x = similar(y);
>
> @time foo!(x, y);
>
>
> gives (after running @time twice to eliminate the compilation time):
>
>
>   0.000035 seconds (5 allocations: 176 bytes)
>
>
> i.e. it is not allocating any arrays, and all the loops are fused.
>
>
> Binary operations like .+ will not be fused until Julia 0.6, however. 
>  (This is documented in the manual.)
>

Reply via email to