Created
June 24, 2016 10:12
-
-
Save pkofod/95c4fb1d43983b2293b3157c9dc19578 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
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 | |
b[j][:] = d[j]'*rand(10,10) | |
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) | |
BenchmarkTools.Trial: | |
samples: 6536 | |
evals/sample: 1 | |
time tolerance: 5.00% | |
memory tolerance: 1.00% | |
memory estimate: 1.34 mb | |
allocs estimate: 5000 | |
minimum time: 681.45 μs (0.00% GC) | |
median time: 700.28 μs (0.00% GC) | |
mean time: 763.74 μs (7.17% GC) | |
maximum time: 2.50 ms (61.59% GC) | |
julia> @benchmark fast_slow!(C, F) | |
BenchmarkTools.Trial: | |
samples: 5794 | |
evals/sample: 1 | |
time tolerance: 5.00% | |
memory tolerance: 1.00% | |
memory estimate: 1.44 mb | |
allocs estimate: 9467 | |
minimum time: 743.66 μs (0.00% GC) | |
median time: 755.04 μs (0.00% GC) | |
mean time: 861.39 μs (11.62% GC) | |
maximum time: 2.71 ms (68.97% GC) | |
julia> @benchmark slow!(B, E) | |
BenchmarkTools.Trial: | |
samples: 6381 | |
evals/sample: 1 | |
time tolerance: 5.00% | |
memory tolerance: 1.00% | |
memory estimate: 1.19 mb | |
allocs estimate: 4000 | |
minimum time: 718.93 μs (0.00% GC) | |
median time: 730.01 μs (0.00% GC) | |
mean time: 782.54 μs (6.26% GC) | |
maximum time: 2.17 ms (60.21% GC) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment