Skip to content

Instantly share code, notes, and snippets.

@pkofod
Last active October 7, 2015 20:20
Show Gist options
  • Save pkofod/fb6c4b8ffcca1a056363 to your computer and use it in GitHub Desktop.
Save pkofod/fb6c4b8ffcca1a056363 to your computer and use it in GitHub Desktop.
using Devectorize
function test0()
vector = rand(8000)
phat = zeros(8000)
@time for i = 1:1000
for j = 1:8000
phat[j] = 1./(1+exp(-vector [j]))
end
end
end
function test1()
vector = rand(8000)
phat = zeros(8000)
@time for i = 1:1000
phat[:] = 1./(1+exp(-vector))
end
end
function test2()
vector = rand(8000)
phat = zeros(8000)
@time for i = 1:1000
@devec phat[:] = 1./(1+exp(-vector))
end
end
type ML
vector
phat
end
ml = ML(rand(8000), zeros(8000))
function test3(ml)
@time for i = 1:1000
ml.phat[:] = 1./(1+exp(-ml.vector))
end
end
function test4(ml)
@time for i = 1:1000
@devec ml.phat[:] = 1./(1+exp(-ml.vector))
end
end
function test5(a, b)
@time for i = 1:1000
@devec a[:] = 1./(1+exp(-b))
end
end
function test6(a)
@time for i = 1:1000
for j = 1:8000
a.phat[j] = 1./(1+exp(-a.vector[j]))
end
end
end
test1()
test2()
test3(ml)
test4(ml)
test5(ml.phat, ml.vector)
test6(ml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment