Skip to content

Instantly share code, notes, and snippets.

@abelsiqueira
Created January 17, 2017 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abelsiqueira/89e1113f8e6204ca48ea4bb25c5e1314 to your computer and use it in GitHub Desktop.
Save abelsiqueira/89e1113f8e6204ca48ea4bb25c5e1314 to your computer and use it in GitHub Desktop.
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