From: "S_H_ (Shun Hiraoka)" Date: 2021-11-17T14:47:40+00:00 Subject: [ruby-core:106110] [Ruby master Feature#18344] Improve performance Kernel#Float with using Primitive.mandatory_only? method Issue #18344 has been reported by S_H_ (Shun Hiraoka). ---------------------------------------- Feature #18344: Improve performance Kernel#Float with using Primitive.mandatory_only? method https://bugs.ruby-lang.org/issues/18344 * Author: S_H_ (Shun Hiraoka) * Status: Open * Priority: Normal ---------------------------------------- Recently, introduce `Primitive.mandatory_only?` method(to improve performance Time.at methods). And, I tried to if can improve `Kernel#Float` method perfomance with using `Primitive.mandatory_only?` method. benchmark: ```yml benchmark: float: "Float(42)" float_true: "Float(42, exception: true)" float_false: "Float(42, exception: false)" loop_count: 10000 ``` result: ``` sh@DESKTOP-L0NI312:~/rubydev/build$ make benchmark/kernel_float.yml -e COMPARE_RUBY=~/.rbenv/shims/ruby -e BENCH_RUBY=../install/bin/ruby -e BENCH_OPTS=--repeat-count=4 generating vm_call_iseq_optimized.inc vm_call_iseq_optimized.inc unchanged Calculating ------------------------------------- compare-ruby built-ruby float 41.000M 47.416M i/s - 10.000k times in 0.000244s 0.000211s float_true 10.875M 21.317M i/s - 10.000k times in 0.000920s 0.000469s float_false 13.910M 22.847M i/s - 10.000k times in 0.000719s 0.000438s Comparison: float built-ruby: 47415837.0 i/s compare-ruby: 41000410.0 i/s - 1.16x slower float_true built-ruby: 21317416.4 i/s compare-ruby: 10875475.8 i/s - 1.96x slower float_false built-ruby: 22846698.6 i/s compare-ruby: 13910140.5 i/s - 1.64x slower ``` `COMPARE_RUBY` is `ruby 3.1.0dev (2021-11-17T13:21:42Z master b95d7d2099) [x86_64-linux]`. BENCH_RUBY is ahead of `ruby 3.1.0dev (2021-11-17T13:21:42Z master b95d7d2099) [x86_64-linux]`. -- https://bugs.ruby-lang.org/ Unsubscribe: