Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. function testVec(t,v,k,n)
  2. for i=1:n
  3. t .= v .* 3 .+ k .* 4;
  4. end
  5. end
  6.  
  7. module params
  8. r = 3;
  9. end
  10.  
  11. function testVec2(t,v,k,n)
  12. for i=1:n
  13. t .= v .* params.r .+ k .* 4;
  14. end
  15. end
  16.  
  17. @time testVec([1 2 3 4], [2 3 4 5], [3 4 5 6], 1000)
  18. 0.000036 seconds (7 allocations: 496 bytes)
  19.  
  20. @time testVec2([1 2 3 4], [2 3 4 5], [3 4 5 6], 1000)
  21. 0.003180 seconds (4.01 k allocations: 141.109 KiB)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement