Last active
December 18, 2016 01:08
-
-
Save ryanrhymes/b8bf0d3df8e99d36896cc4a1ceefaefc 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
shape = (10,1000,10000) | |
function f00() | |
t0 = time() | |
x = [] | |
t1 = time() | |
@printf "empty:\t\t%.8f\n" (t1 -t0) | |
end | |
function f01() | |
t0 = time() | |
x = fill(3.5, shape) | |
t1 = time() | |
@printf "create:\t\t%.8f\n" (t1 -t0) | |
end | |
function f04() | |
x = fill(3.5, shape) | |
y = fill(5.5, shape) | |
t0 = time() | |
z = x + y | |
t1 = time() | |
@printf "x + y:\t\t%.8f\n" (t1 -t0) | |
end | |
function f05() | |
x = fill(3.5, shape) | |
y = fill(5.5, shape) | |
t0 = time() | |
z = x .* y | |
t1 = time() | |
@printf "x * y:\t\t%.8f\n" (t1 -t0) | |
end | |
function f06() | |
x = fill(3.5, shape) | |
t0 = time() | |
z = x + 2 | |
t1 = time() | |
@printf "x + 2:\t\t%.8f\n" (t1 -t0) | |
end | |
function f07() | |
x = fill(3.5, shape) | |
t0 = time() | |
z = abs(x) | |
t1 = time() | |
@printf "abs(x):\t\t%.8f\n" (t1 -t0) | |
end | |
function f08() | |
x = fill(3.5, shape) | |
t0 = time() | |
z = map(a -> sin(a)+1,x) | |
t1 = time() | |
@printf "map(sin(a)^2):\t%.8f\n" (t1 -t0) | |
end | |
function f09() | |
x = fill(3.5, shape) | |
t0 = time() | |
for a in x | |
a > 0 | |
end | |
t1 = time() | |
@printf "iter:\t\t%.8f\n" (t1 -t0) | |
end | |
function f10() | |
x = fill(3.5, shape) | |
y = fill(5.5, shape) | |
t0 = time() | |
y .< x | |
t1 = time() | |
@printf "x .< y:\t\t%.8f\n" (t1 -t0) | |
end | |
function f90() | |
t0 = time() | |
z = sum(x) | |
t1 = time() | |
@printf "sum(x):\t\t%.8f\n" (t1 -t0) | |
end | |
function f91() | |
t0 = time() | |
z = map(sin,x) | |
t1 = time() | |
@printf "map(sin):\t%.8f\n" (t1 -t0) | |
end | |
function f93() | |
t0 = time() | |
z = map(a -> sin(a*a),x) | |
t1 = time() | |
@printf "map(^2):\t%.8f\n" (t1 -t0) | |
end | |
function f94() | |
square(x) = x^2 | |
@vectorize_1arg Number square | |
methods(square) | |
t0 = time() | |
square(x) | |
t1 = time() | |
@printf "square:\t\t%.8f\n" (t1 -t0) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment