Skip to content

Instantly share code, notes, and snippets.

@pkofod
Created June 24, 2016 10:07
Show Gist options
  • Save pkofod/0a3b1ab43cd18951781dd29e9cb7f08f to your computer and use it in GitHub Desktop.
Save pkofod/0a3b1ab43cd18951781dd29e9cb7f08f to your computer and use it in GitHub Desktop.
using BenchmarkTools
A = rand(10000)
B = Vector[rand(10) for i = 1:1000]
C = rand(10,1000)
D = rand(10000)
E = Vector[rand(10) for i = 1:1000]
F = rand(10, 1000)
function fast!(a, c)
for j = 1:1000
a[1+(j-1)*10:j*10] = c[1+(j-1)*10:j*10]'*rand(10,10)
end
end
function fast_slow!(c, f)
for j = 1:1000
c[:, j] = f[:, j]'*rand(10,10)
end
end
function slow!(b, d)
for j = 1:1000
for i = 1:10
b[j][:] = d[j]'*rand(10,10)
end
end
end
fast!(A, D)
fast_slow!(C, F)
slow!(B, E)
@benchmark fast!(A, C)
@benchmark fast_slow!(C, F)
@benchmark slow!(B, E)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment