summaryrefslogtreecommitdiff
path: root/benchmark/io_write.rb
blob: cdb409948b16b661ac3186e82c223e16c6cf9df3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env ruby

require 'benchmark'

i, o = IO.pipe
o.sync = true

DOT = ".".freeze

chunks = 100_000.times.collect{DOT}

thread = Thread.new do
  while i.read(1024)
  end
end

100.times do
  o.write(*chunks)
end

o.close
thread.join