mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add IO write throughput/locking overhead benchmark.
This commit is contained in:
parent
15ebfe2849
commit
216593f59b
Notes:
git
2022-05-28 12:44:47 +09:00
1 changed files with 22 additions and 0 deletions
22
benchmark/io_write.rb
Normal file
22
benchmark/io_write.rb
Normal file
|
@ -0,0 +1,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
|
Loading…
Add table
Reference in a new issue