Last active
August 29, 2015 14:18
-
-
Save simonbyrne/91c0aa3350a45d9068a3 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
function sincos(x::Float64) | |
s = Ref{Float64}() | |
c = Ref{Float64}() | |
ccall((:sincos,Base.Math.libm),Void,(Float64,Ref{Float64},Ref{Float64}),x,s,c) | |
return s.x, c.x | |
end | |
function test_sep(X) | |
t = 0.0 | |
for x in X | |
t += sin(x) + cos(x) | |
end | |
t | |
end | |
function test_comb(X) | |
t = 0.0 | |
for x in X | |
s,c = sincos(x) | |
t += s+c | |
end | |
t | |
end | |
X = 10*rand(10_000_000) | |
@time test_sep(X) | |
@time test_comb(X) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment