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.
This commit is contained in:
Jean Boussier 2022-08-08 11:14:05 +02:00
Родитель 289d219758
Коммит 1cb77f2304
1 изменённых файлов: 9 добавлений и 8 удалений

Просмотреть файл

@ -1,9 +1,10 @@
prelude: |
# frozen_string_literal: true
Warning[:experimental] = false
buffer = IO::Buffer.new(32, IO::Buffer::MAPPED)
string = "\0" * 32
benchmark: benchmark:
- name: buffer.get buffer.get_value: |
prelude: buffer = IO::Buffer.new(32, IO::Buffer::MAPPED) buffer.get_value(:U32, 0)
script: buffer.get(:U32, 0) string.unpack1: |
loop_count: 20000000 string.unpack1("N")
- name: string.unpack
prelude: string = "\0" * 32
script: string.unpack("C")
loop_count: 20000000