I don’t understand why the latter two calls below use twice the memory and are much slower than the first call. I had thought this type of broadcasting should work efficiently now but maybe I misunderstood? I’ve checked both on v0.6.0-pre.alpha as well as master.
$ julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _ | |
| | |_| | | | (_| | | Version 0.6.0-pre.alpha.137 (2017-03-13 14:27 UTC)
_/ |\__'_|_|_|\__'_| | Commit a132ae2* (0 days old master)
|__/ | x86_64-linux-gnu
julia> a = b = rand(100,100);
julia> using BenchmarkTools
julia> @benchmark a .+ b .+ a
BenchmarkTools.Trial:
memory estimate: 79.33 KiB
allocs estimate: 27
--------------
minimum time: 23.414 μs (0.00% GC)
median time: 27.117 μs (0.00% GC)
mean time: 31.874 μs (8.69% GC)
maximum time: 1.079 ms (92.62% GC)
--------------
samples: 10000
evals/sample: 1
time tolerance: 5.00%
memory tolerance: 1.00%
julia> @benchmark (a,) .* (b,) .* (a,)
BenchmarkTools.Trial:
memory estimate: 156.45 KiB
allocs estimate: 7
--------------
minimum time: 75.679 μs (0.00% GC)
median time: 84.202 μs (0.00% GC)
mean time: 179.888 μs (3.84% GC)
maximum time: 23.779 ms (0.00% GC)
--------------
samples: 10000
evals/sample: 1
time tolerance: 5.00%
memory tolerance: 1.00%
julia> @benchmark [a] .* [b] .* [a]
BenchmarkTools.Trial:
memory estimate: 158.34 KiB
allocs estimate: 56
--------------
minimum time: 124.935 μs (0.00% GC)
median time: 134.950 μs (0.00% GC)
mean time: 151.803 μs (4.55% GC)
maximum time: 6.196 ms (0.00% GC)
--------------
samples: 10000
evals/sample: 1
time tolerance: 5.00%
memory tolerance: 1.00%