Skip to content

Commit 1cb77f2

Browse files
committed
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.
1 parent 289d219 commit 1cb77f2

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

benchmark/buffer_get.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
prelude: |
2+
# frozen_string_literal: true
3+
Warning[:experimental] = false
4+
buffer = IO::Buffer.new(32, IO::Buffer::MAPPED)
5+
string = "\0" * 32
16
benchmark:
2-
- name: buffer.get
3-
prelude: buffer = IO::Buffer.new(32, IO::Buffer::MAPPED)
4-
script: buffer.get(:U32, 0)
5-
loop_count: 20000000
6-
- name: string.unpack
7-
prelude: string = "\0" * 32
8-
script: string.unpack("C")
9-
loop_count: 20000000
7+
buffer.get_value: |
8+
buffer.get_value(:U32, 0)
9+
string.unpack1: |
10+
string.unpack1("N")

0 commit comments

Comments
 (0)