1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/benchmark/buffer_each.yml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
654 B
YAML
Raw Normal View History

prelude: |
# frozen_string_literal: true
Warning[:experimental] = false
string = "The quick brown fox jumped over the lazy dog."
array = string.bytes
buffer = IO::Buffer.for(string)
benchmark:
string.each_byte: |
upcased = String.new
string.each_byte do |byte|
upcased << (byte ^ 32)
end
array.each: |
upcased = String.new
array.each do |byte|
upcased << (byte ^ 32)
end
buffer.each: |
upcased = String.new
buffer.each(:U8) do |offset, byte|
upcased << (byte ^ 32)
end
buffer.each_byte: |
upcased = String.new
buffer.each_byte do |byte|
upcased << (byte ^ 32)
end