Issue #17670 has been reported by S_H_ (Shun Hiraoka).

----------------------------------------
Feature #17670: Improve performance Float#to_i
https://bugs.ruby-lang.org/issues/17670

* Author: S_H_ (Shun Hiraoka)
* Status: Open
* Priority: Normal
----------------------------------------

Improve performance `Float#to_i` and `Float#to_int` methods(write in Ruby)

benchmark:
```yml
prelude: |
  flo = 4.2
benchmark:
  to_i: |
    flo.to_i
  to_int: |
    flo.to_int
loop_count: 20000000

```

result:
```bash
sh@DESKTOP-L0NI312:~/rubydev/build$ make benchmark/benchmark.yml -e COMPARE_RUBY=~/.rbenv/shims/ruby -e BENCH_RUBY=../install/bin/ruby
generating vm_call_iseq_optimized.inc
vm_call_iseq_optimized.inc unchanged
compare-ruby: ruby 3.1.0dev (2021-02-28T11:24:42Z master 80e2c45f55) [x86_64-linux]
built-ruby: ruby 3.1.0dev (2021-02-28T11:24:42Z master 80e2c45f55) [x86_64-linux]
# Iteration per second (i/s)

|        |compare-ruby|built-ruby|
|:-------|-----------:|---------:|
|to_i    |     66.872M|   75.080M|
|        |           -|     1.12x|
|to_int  |     65.597M|   75.298M|
|        |           -|     1.15x|
```

`COMPARE_RUBY` is `ruby 3.1.0dev (2021-02-28T11:24:42Z master 80e2c45f55) [x86_64-linux]`. `BENCH_RUBY` is ahead of `ruby 3.1.0dev (2021-02-28T11:24:42Z master 80e2c45f55) [x86_64-linux]`.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>