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
Jean Boussier 1cb77f2304 Update IO::Buffer#get_value benchmark
- The method was renamed from `get` to `get_value`
- Comparing to `String#unpack` isn't quite equivalent, `unpack1` is closer.
- Use frozen_string_literal to avoid allocating a format string every time.
- Use `N` format which is equivalent to `:U32` (`uint_32_t` big-endian).
- Disable experimental warnings to not mess up the output.
2022-08-08 15:15:33 +02:00

10 lines
254 B
YAML

prelude: |
# frozen_string_literal: true
Warning[:experimental] = false
buffer = IO::Buffer.new(32, IO::Buffer::MAPPED)
string = "\0" * 32
benchmark:
buffer.get_value: |
buffer.get_value(:U32, 0)
string.unpack1: |
string.unpack1("N")