Created
January 17, 2017 23:55
-
-
Save abelsiqueira/89e1113f8e6204ca48ea4bb25c5e1314 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, Plots | |
function foo() | |
N = 20 | |
T1 = zeros(N, 3) | |
T2 = zeros(N, 3) | |
for i = 1:N | |
n = 2^i | |
println("Running for $n") | |
x = rand(n) | |
y = rand(n) | |
t1 = @benchmark BLAS.dot($n, $x, 1, $y, 1) | |
t2 = @benchmark dot($x,$y) | |
t1 = t1.times | |
t2 = t2.times | |
T1[i,:] = [minimum(t1), mean(t1), maximum(t1)] | |
T2[i,:] = [minimum(t2), mean(t2), maximum(t2)] | |
end | |
t = 2.^(1:N) | |
plot(xaxis = :log, yaxis=:log) | |
plot!(t, T1[:,1], color=:red, l=:dash, lab="") | |
plot!(t, T1[:,2], color=:red, l=:solid, lab="BLAS.dot") | |
plot!(t, T1[:,3], color=:red, l=:dot, lab="") | |
plot!(t, T2[:,1], color=:blue, l=:dash, lab="") | |
plot!(t, T2[:,2], color=:blue, l=:solid, lab="dot") | |
plot!(t, T2[:,3], color=:blue, l=:dot, lab="") | |
png("blas_bench") | |
end | |
foo() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment