Guest User

Untitled

a guest
Jan 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. require 'benchmark'
  2.  
  3. GC.start
  4. m1 = Benchmark.measure do
  5. 1_000_000.times do
  6. arr = [[1.1, 2.2, 3.3], [4.1, 5.6, 6.8], [7.1, 8.7, 9.0], [10.0, 11.4, 12.6]]
  7. arr.map{|y| y.map{|z| z.to_i}}
  8. end
  9. end
  10.  
  11. GC.start
  12. m2 = Benchmark.measure do
  13. 1_000_000.times do
  14. arr = [[1.1, 2.2, 3.3], [4.1, 5.6, 6.8], [7.1, 8.7, 9.0], [10.0, 11.4, 12.6]]
  15. arr.each{|y| y.map!{|z| z.to_i}}
  16. end
  17. end
  18.  
  19. puts m1, m2
Add Comment
Please, Sign In to add comment