Project

General

Profile

Feature #4531 ยป 0001-add-io-wait-benchmarks.patch

normalperson (Eric Wong), 05/05/2011 06:53 AM

View differences:

benchmark/bm_io_wait.rb
1
# IO#wait performance
2
require "io/wait"
3
r, w = IO.pipe
4
w.syswrite '.'
5

  
6
nr = 1000000
7
nr.times {
8
  r.wait
9
}
benchmark/bm_io_wait2.rb
1
# IO#wait performance. worst case of single fd.
2
require "io/wait"
3

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

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

  
13
r, w = IO.pipe
14
w.syswrite '.'
15
puts "last IO: #{r.inspect}"
16

  
17
nr.times do
18
  r.wait
19
end