Slide 13
Slide 13 text
funcMon
bar(x)
return
[x,
x+1,
x+2]
end
funcMon
foo()
for
i
=
1:10^7
a
=
bar(i)
end
end
elapsed
(me:
1.453459727
seconds
(1279975568
bytes
allocated)
funcMon
bar!{T}(ret::AbstractVector{T},
x::T)
ret[1]
=
x
ret[2]
=
x+1
ret[3]
=
x+2
end
funcMon
foo()
a
=
Array(Int,
3)
for
i
=
1:10^7
bar!(a,
i)
end
elapsed
(me:
0.038737026
seconds
(117992
bytes
allocated)
関数の返り値を事前に定義しておく