Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save NaelsonDouglas/76a0fd3b9726724030b292c7b571d85d to your computer and use it in GitHub Desktop.

Select an option

Save NaelsonDouglas/76a0fd3b9726724030b292c7b571d85d to your computer and use it in GitHub Desktop.
#Função aleatória que usa muitas operações em matrizes
@acc f(x::Array{Int64}) = x .* x .+ x .* x .- x ./ x
input = Int64[1:10000]
print("\n Input x length: ",length(input),"\n \n")
for(loop=1:10)
acc = @elapsed f(input)
noacc = @elapsed @noacc f(input)
print("Time to perform with acc: ", acc,"\n")
print("Time to perform without acc: ", noacc,"\n")
if (noacc > acc)
print("acc was ",noacc/acc," times faster than noacc\n")
else
print("nacc was ",acc/noacc," times faster than acc\n")
end
print("\n \n")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment