Thanks for all the answers. Comparing two of the options
function mapround(b)
map(x -> round.(x), b)
end
function nomapround(b)
(x -> round.(x)).(b)
end
a = (1.234567,7.654321)
b = [a; a; a; a; a; a; a;]
@time mapround(b)
@time nomapround(b)
0.000002 seconds (6 allocations: 368 bytes)
0.000002 seconds (5 allocations: 352 bytes)
So it seems the second option saves me one allocation. Do I understand it correctly that the second option would also allow for loop fusion in larger dot expressions while map would not?
You are conflating compilation time and runtime. Benchmark using BenchmarkTools:
using Compat # workaround for an issue
using BenchmarkTools
mapround(b) = map(x -> round.(x), b)
nomapround(b) = (x -> round.(x)).(b)
a = (1.234567,7.654321)
b = fill(a, 7)
@benchmark mapround($b)
@benchmark nomapround($b)
Sorry, I was not aware that you ran @time multiple times (it is a good thing to do, but your code did not indicate this). If you did, you were indeed not measuring compilation. But you still get benchmarking noise.