using BenchmarkTools
julia> @btime reshape([1],1,1)
63.990 ns (3 allocations: 192 bytes)
1×1 Array{Int64,2}:
1
julia> @btime fill(1, (1,1))
29.674 ns (1 allocation: 96 bytes)
1×1 Array{Int64,2}:
1
julia> @btime hcat(1)
33.067 ns (1 allocation: 96 bytes)
1×1 Array{Int64,2}:
1
The difference between hcat
and fill
is small, but consistent. I also find fill
more elegant.