summaryrefslogtreecommitdiff
path: root/benchmark/buffer_each.yml
blob: 417941104ecef2aabb3e7589f10383e60108faec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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