Project

General

Profile

Actions

Feature #19085

closed

Improve performance some Integer and Float methods

Added by S_H_ (Shun Hiraoka) over 1 year ago. Updated over 1 year ago.

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

Description

Improve performance some Integer and Float methods written by Ruby.

benchmark:

prelude: |
  int_num = 42
  flo_num = 4.2
benchmark:
  integer_real: |
    int_num.real
  float_real: |
    flo_num.real
  integr_imag: |
    int_num.imag
  float_imag: |
    flo_num.imag
  integer_conj: |
    int_num.conj
  float_conj: |
    flo_num.conj
  integer_numerator: |
    int_num.numerator
  integer_denominator: |
    int_num.denominator
loop_count: 20000000

result:

sh@DESKTOP-L0NI312:~/rubydev/build$ make benchmark/benchmark.yml -e BENCH_RUBY=../install/bin/ruby -e COMPARE_RUBY=~/.rbenv/shims/ruby
../ruby/revision.h unchanged
compare-ruby: ruby 3.2.0dev (2022-10-26T06:02:04Z master 94f3aa2126) [x86_64-linux]
built-ruby: ruby 3.2.0dev (2022-10-26T12:38:10Z improve_integer_an.. 2044b65fb2) [x86_64-linux]
# Iteration per second (i/s)

|                     |compare-ruby|built-ruby|
|:--------------------|-----------:|---------:|
|integer_real         |     79.510M|   82.640M|
|                     |           -|     1.04x|
|float_real           |     80.673M|   83.534M|
|                     |           -|     1.04x|
|integr_imag          |     81.043M|   86.709M|
|                     |           -|     1.07x|
|float_imag           |     80.303M|   80.680M|
|                     |           -|     1.00x|
|integer_conj         |     78.219M|   85.795M|
|                     |           -|     1.10x|
|float_conj           |     75.137M|   84.604M|
|                     |           -|     1.13x|
|integer_numerator    |     78.194M|   79.461M|
|                     |           -|     1.02x|
|integer_denominator  |     73.674M|   87.035M|
|                     |           -|     1.18x|

COMPARE_RUBY is ruby 3.2.0dev (2022-10-26T06:02:04Z master 94f3aa2126) [x86_64-linux]. BENCH_RUBY is ahead of ruby 3.2.0dev (2022-10-26T06:02:04Z master 94f3aa2126) [x86_64-linux].

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

Actions #1

Updated by S_H_ (Shun Hiraoka) over 1 year ago

  • Status changed from Open to Closed

Applied in changeset git|c6f439a6a8df582416e756d7511aa4d9c72071a9.


Improve performance some Integer and Float methods [Feature #19085] (#6638)

  • Improve some Integer and Float methods

  • Using alias and Remove unnecessary code

  • Remove commentout code

Actions

Also available in: Atom PDF

Like0
Like0