summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2022-01-09 19:46:42 +1300
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2022-05-28 15:44:18 +1200
commit216593f59b49fc7f59ed991ae3feaa1ad233ce75 (patch)
tree498e6b5e12cb89fab4a78bc82973ff830e57e75a /benchmark
parent15ebfe28493560f8368fc9a2fe7d9b5913051b84 (diff)
Add IO write throughput/locking overhead benchmark.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5419
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/io_write.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/benchmark/io_write.rb b/benchmark/io_write.rb
new file mode 100644
index 0000000000..cdb409948b
--- /dev/null
+++ b/benchmark/io_write.rb
@@ -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