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_get.yml

26 lines
658 B
YAML
Raw Normal View History

prelude: |
# frozen_string_literal: true
Warning[:experimental] = false
string = "The quick brown fox jumped over the lazy dog."
buffer = IO::Buffer.for(string)
format = [:U32, :U32, :U32, :U32]
2021-07-02 06:41:16 -04:00
benchmark:
string.unpack1: |
[
string.unpack1("N"),
string.unpack1("N", offset: 4),
string.unpack1("N", offset: 8),
string.unpack1("N", offset: 12),
]
buffer.get_value: |
[
buffer.get_value(:U32, 0),
buffer.get_value(:U32, 4),
buffer.get_value(:U32, 8),
buffer.get_value(:U32, 12),
]
buffer.get_values: |
buffer.get_values(format, 0)
string.unpack: |
string.unpack("NNNN")