ruby/benchmark/buffer_each.yml

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

28 строки
654 B
YAML
Исходник Обычный вид История

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