Project

General

Profile

Actions

Feature #17670

closed

Improve performance Float#to_i

Added by S_H_ (Shun Hiraoka) about 3 years ago. Updated over 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:102715]

Description

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

benchmark:

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

result:

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 improve_float_to_i 80e2c45f55) [x86_64-linux]
# Iteration per second (i/s)

|        |compare-ruby|built-ruby|
|:-------|-----------:|---------:|
|to_i    |     69.184M|   78.294M|
|        |           -|     1.13x|
|to_int  |     69.891M|   80.285M|
|        |           -|     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].

pull request: https://github.com/ruby/ruby/pull/4234

Actions #1

Updated by S_H_ (Shun Hiraoka) about 3 years ago

  • Description updated (diff)
Actions #2

Updated by S_H_ (Shun Hiraoka) about 3 years ago

  • Description updated (diff)

Updated by ko1 (Koichi Sasada) over 2 years ago

  • Status changed from Open to Closed

closed on GH PR

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0