Benchmarks of Multidimensional Stack Implementations in Julia


Datastructures.jl claims it's fast. How does it do? I wrote some quick codes to check it out. What I wanted to do is find out which algorithm does best for implementing a stack where each element is three integers. I tried filling a pre-allocated array, pushing into three separate vectors, and different implementations of the stack from the DataStructures.jl package.

function baseline()
stack = Array{Int64,2}(1000000,3)
for i=1:1000000,j=1:3
stack[i,j]=i
end
end
function baseline2()
stack = Array{Int64,2}(1000000,3)
for j=1:3,i=1:1000000
stack[i,j]=i
end
end
function f0()
stack = Array{Int64}(1000000,3)
for i = 1:1000000
stack[i,:] = [i,i,i]
end
end
function f02()
stack = Array{Int64}(3,1000000)
for i = 1:1000000
stack[:,i] = [i;i;i]
end
end
function f1()
stack1 = Vector{Int64}(1)
stack2 ... READ MORE