2011-04-30 11:49:29 +04:00
|
|
|
# IO.select performance. worst case of single fd.
|
2011-04-30 11:16:31 +04:00
|
|
|
|
|
|
|
ios = []
|
|
|
|
nr = 1000000
|
2011-11-17 15:24:07 +04:00
|
|
|
if defined?(Process::RLIMIT_NOFILE)
|
|
|
|
max = Process.getrlimit(Process::RLIMIT_NOFILE)[0]
|
|
|
|
else
|
|
|
|
max = 64
|
|
|
|
end
|
2011-04-30 11:16:31 +04:00
|
|
|
puts "max fd: #{max} (results not apparent with <= 1024 max fd)"
|
|
|
|
|
2011-05-04 16:13:02 +04:00
|
|
|
((max / 2) - 10).times do
|
2011-04-30 11:16:31 +04:00
|
|
|
ios.concat IO.pipe
|
|
|
|
end
|
|
|
|
|
|
|
|
last = [ ios[-1] ]
|
|
|
|
puts "last IO: #{last[0].inspect}"
|
|
|
|
|
|
|
|
nr.times do
|
|
|
|
IO.select nil, last
|
|
|
|
end
|
|
|
|
|