Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'benchmark'
- # Benchmarks for IO/File
- #
- # user system total real
- # reference 0.000000 0.000000 0.000000 ( 0.001515)
- # IO.open(0) 0.170000 0.020000 0.190000 ( 0.193146)
- # IO.open(2) 0.470000 0.020000 0.490000 ( 0.487771)
- # File.open 0.820000 0.110000 0.930000 ( 0.930175)
- #
- Benchmark.bm(20) do |x|
- n = 10000
- x.report("reference") do
- n.times { $stdout }
- end
- x.report("IO.open(0)") do
- n.times { IO.open(1) }
- end
- x.report("IO.open(1)") do
- n.times { IO.open(1) }
- end
- x.report("File.open") do
- n.times { File.open(__FILE__) {} }
- end
- end
Add Comment
Please, Sign In to add comment