Project

General

Profile

Actions

Feature #19097

open

Improve performance some Float and IO class constants

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

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:110569]

Description

Improve performance some Float and IO class constants written by Ruby.

benchmark:

benchmark:
  Float_RADIX: |
    Float::RADIX
  Float_MANT_DIG: |
    Float::MANT_DIG
  Float_DIG: |
    Float::DIG
  Float_MIN_EXP: |
    Float::MIN_EXP
  Float_MAX_EXP: |
    Float::MAX_EXP
  Float_MIN_10_EXP: |
    Float::MIN_10_EXP
  Float_MAX_10_EXP: |
    Float::MAX_10_EXP
  Float_MIN: |
    Float::MIN
  Float_MAX: |
    Float::MAX
  Float_EPSILON: |
    Float::EPSILON
  Float_INFINITY: |
    Float::INFINITY
  Float_NAN: |
    Float::NAN
  IO_READABLE:
    IO::READABLE
  IO_WRITABLE: |
    IO::WRITABLE
  IO_PRIORITY: |
    IO::PRIORITY
  IO_SEEK_SET: |
    IO::SEEK_SET
  IO_SEEK_CUR: |
    IO::SEEK_CUR
  IO_SEEK_END: |
    IO::SEEK_END
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-11-01T05:34:05Z master 6bf458eefd) [x86_64-linux]
built-ruby: ruby 3.2.0dev (2022-11-02) [x86_64-linux]
# Iteration per second (i/s)

|                  |compare-ruby|built-ruby|
|:-----------------|-----------:|---------:|
|Float_RADIX       |    228.823M|  761.580M|
|                  |           -|     3.33x|
|Float_MANT_DIG    |    222.657M|  306.364M|
|                  |           -|     1.38x|
|Float_DIG         |    217.899M|  301.107M|
|                  |           -|     1.38x|
|Float_MIN_EXP     |    223.007M|  258.014M|
|                  |           -|     1.16x|
|Float_MAX_EXP     |    222.264M|  311.401M|
|                  |           -|     1.40x|
|Float_MIN_10_EXP  |    206.392M|  298.762M|
|                  |           -|     1.45x|
|Float_MAX_10_EXP  |    205.242M|  310.312M|
|                  |           -|     1.51x|
|Float_MIN         |    219.295M|  339.811M|
|                  |           -|     1.55x|
|Float_MAX         |    217.156M|  295.903M|
|                  |           -|     1.36x|
|Float_EPSILON     |    199.553M|  299.349M|
|                  |           -|     1.50x|
|Float_INFINITY    |    217.590M|  317.187M|
|                  |           -|     1.46x|
|Float_NAN         |    218.890M|  275.118M|
|                  |           -|     1.26x|
|IO_READABLE       |    287.937M|  289.072M|
|                  |           -|     1.00x|
|IO_WRITABLE       |    215.121M|  294.124M|
|                  |           -|     1.37x|
|IO_PRIORITY       |    210.967M|  337.100M|
|                  |           -|     1.60x|
|IO_SEEK_SET       |    228.084M|  294.323M|
|                  |           -|     1.29x|
|IO_SEEK_CUR       |    229.345M|  305.353M|
|                  |           -|     1.33x|
|IO_SEEK_END       |    219.930M|  275.197M|
|                  |           -|     1.25x|

COMPARE_RUBY is ruby 3.2.0dev (2022-11-01T05:34:05Z master 6bf458eefd) [x86_64-linux]. BENCH_RUBY is ahead of ruby 3.2.0dev (2022-11-01T05:34:05Z master 6bf458eefd) [x86_64-linux].

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

No data to display

Actions

Also available in: Atom PDF

Like0