Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
djberg96 committed Apr 15, 2023
1 parent 6a66a9b commit 1b0277d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions examples/writev_benchmark.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'benchmark'
require 'io-extra'

a = (0..1023).to_a.map(&:to_s)

file1 = 'write_test.txt'
file2 = 'writev_test.txt'

fh = File.open(file2, 'w')

Benchmark.bm(25) do |x|
x.report('write'){ 100000.times{ File.write(file1, a.join) } }
x.report('writev'){ 100000.times{ IO.writev(fh.fileno, a) } }
end

fh.close

File.delete(file1)
File.delete(file2)

0 comments on commit 1b0277d

Please sign in to comment.