Guest User

Untitled

a guest
Apr 25th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. require 'benchmark'
  2.  
  3. # Benchmarks for IO/File
  4. #
  5. # user system total real
  6. # reference 0.000000 0.000000 0.000000 ( 0.001515)
  7. # IO.open(0) 0.170000 0.020000 0.190000 ( 0.193146)
  8. # IO.open(2) 0.470000 0.020000 0.490000 ( 0.487771)
  9. # File.open 0.820000 0.110000 0.930000 ( 0.930175)
  10. #
  11. Benchmark.bm(20) do |x|
  12. n = 10000
  13.  
  14. x.report("reference") do
  15. n.times { $stdout }
  16. end
  17.  
  18. x.report("IO.open(0)") do
  19. n.times { IO.open(1) }
  20. end
  21.  
  22. x.report("IO.open(1)") do
  23. n.times { IO.open(1) }
  24. end
  25.  
  26. x.report("File.open") do
  27. n.times { File.open(__FILE__) {} }
  28. end
  29. end
Add Comment
Please, Sign In to add comment