[前][次][番号順一覧][スレッド一覧]

ruby-changes:72856

From: Jean <ko1@a...>
Date: Mon, 8 Aug 2022 22:16:01 +0900 (JST)
Subject: [ruby-changes:72856] 1cb77f2304 (master): Update IO::Buffer#get_value benchmark

https://git.ruby-lang.org/ruby.git/commit/?id=1cb77f2304

From 1cb77f23046dbfd14703241e82bed2bcd69bf6a1 Mon Sep 17 00:00:00 2001
From: Jean Boussier <jean.boussier@g...>
Date: Mon, 8 Aug 2022 11:14:05 +0200
Subject: 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.
---
 benchmark/buffer_get.yml | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/benchmark/buffer_get.yml b/benchmark/buffer_get.yml
index e375dcf85d..bb9ca7e94a 100644
--- a/benchmark/buffer_get.yml
+++ b/benchmark/buffer_get.yml
@@ -1,9 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/buffer_get.yml#L1
+prelude: |
+  # frozen_string_literal: true
+  Warning[:experimental] = false
+  buffer = IO::Buffer.new(32, IO::Buffer::MAPPED)
+  string = "\0" * 32
 benchmark:
-  - name: buffer.get
-    prelude: buffer = IO::Buffer.new(32, IO::Buffer::MAPPED)
-    script: buffer.get(:U32, 0)
-    loop_count: 20000000
-  - name: string.unpack
-    prelude: string = "\0" * 32
-    script: string.unpack("C")
-    loop_count: 20000000
+  buffer.get_value: |
+    buffer.get_value(:U32, 0)
+  string.unpack1: |
+    string.unpack1("N")
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]