Guest User

Untitled

a guest
Jul 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. require 'benchmark'
  2.  
  3. arr = [*0..99999]
  4. num = 100
  5. Benchmark.bmbm do |x|
  6. x.report("sym#to_proc") do
  7. num.times do
  8. arr.each(&:to_i)
  9. end
  10. end
  11.  
  12. x.report("traditional block") do
  13. num.times do
  14. arr.each {|i| i.to_i}
  15. end
  16. end
  17. end
  18.  
  19. # For: arr = [*0..99999] and num = 100
  20. # Rehearsal -----------------------------------------------------
  21. # sym#to_proc 3.130000 0.010000 3.140000 ( 3.137098)
  22. # traditional block 1.470000 0.000000 1.470000 ( 1.477588)
  23. # -------------------------------------------- total: 4.610000sec
  24. #
  25. # user system total real
  26. # sym#to_proc 3.060000 0.010000 3.070000 ( 3.069627)
  27. # traditional block 1.470000 0.000000 1.470000 ( 1.475297)
Add Comment
Please, Sign In to add comment