Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function test1()
- n = 1000000
- a = randn(n)
- b = randn(n)
- c = randn(n)
- for i=1:500
- result = sum(a + b + c)
- end
- end
- function test2()
- n = 1000000
- a = randn(n)
- b = randn(n)
- c = randn(n)
- result = 0.0
- for i=1:500
- for j = 1:length(a)
- result += a[j] + b[j] + c[j]
- end
- end
- result
- end
- @time test1() # elapsed time: 6.3725199699401855 seconds
- @time test2() # elapsed time: 2.0483860969543457 seconds
Add Comment
Please, Sign In to add comment