From: gamelinks007@... Date: 2020-12-21T13:14:04+00:00 Subject: [ruby-core:101586] [Ruby master Feature#17416] Improve performance Kernel#itself Issue #17416 has been reported by S_H_ (Shun Hiraoka). ---------------------------------------- Feature #17416: Improve performance Kernel#itself https://bugs.ruby-lang.org/issues/17416 * Author: S_H_ (Shun Hiraoka) * Status: Open * Priority: Normal ---------------------------------------- Improve performance `Kernel#itself` with Ruby code. like this. ```ruby module Kernel # # call-seq: # obj.itself -> obj # # Returns the receiver. # # string = "my string" # string.itself.object_id == string.object_id #=> true # # def itself return self end end ``` benchmark: ```yaml prelude: | obj = Object.new ary = Array.new str = String.new int = 42 flt = 4.2 benchmark: object: | obj.itself array: | ary.itself string: | str.itself integer: | int.itself float: | flt.itself loop_count: 20000000 ``` benchmark result: ```bash sh@MyComputer:~/rubydev/build$ make benchmark/benchmark.yml -e COMPARE_RUBY=~/.rbenv/shims/ruby -e BENCH_RUBY=../install/bin/ruby # Iteration per second (i/s) | |compare-ruby|built-ruby| |:--------|-----------:|---------:| |object | 58.924M| 70.285M| | | -| 1.19x| |array | 56.428M| 65.275M| | | -| 1.16x| |string | 50.311M| 63.087M| | | -| 1.25x| |integer | 54.838M| 62.510M| | | -| 1.14x| |float | 56.372M| 65.399M| | | -| 1.16x| ``` COMPARE_RUBY is `ruby 3.0.0dev (2020-12-21T09:17:45Z master d84dd66da0) [x86_64-linux]`. BENCH_RUBY is ahead of `ruby 3.0.0dev (2020-12-21T09:17:45Z master d84dd66da0) [x86_64-linux]`. -- https://bugs.ruby-lang.org/ Unsubscribe: