Created
January 18, 2017 09:09
-
-
Save pkofod/12b5587964b9a69a00bdc7130366d045 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkTools | |
K = 5 | |
N = 3 | |
z = [rand(20000, K) for i =1:N] | |
P = [rand(20000) for i = 1:N] | |
cache = zeros(20000, K) | |
function test1(P, z) | |
for i in eachindex(P) | |
cache .= P[i].*z[i] | |
end | |
end | |
function test2(P, z) | |
J, I, K = length(P), size(z[1])... | |
for j = 1:J | |
for k = 1:K | |
for i = 1:I | |
cache[i, k] = P[j][i]*z[j][i,k] | |
end | |
end | |
end | |
end | |
@benchmark test1(P, z) | |
@benchmark test2(P, z) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment