Project

General

Profile

Feature #4531 ยป io_select_using_poll_test.rb

contrived test case - normalperson (Eric Wong), 03/29/2011 01:59 AM

 
1
require "benchmark"
2
ios = []
3
nr = 1000000
4
max = Process.getrlimit(Process::RLIMIT_NOFILE)[0]
5
puts "max fd: #{max} (results not apparent with <= 1024 max fd)"
6

    
7
((max / 2) - 2).times do
8
  ios.concat IO.pipe
9
end
10

    
11
last = [ ios[-1] ]
12
puts "last IO: #{last[0].inspect}"
13

    
14
p(Benchmark.measure do
15
  nr.times do
16
    IO.select nil, last
17
  end
18
end)
19
puts "GC.count: #{GC.count}"