Feature #19076
Updated by S_H_ (Shun Hiraoka) about 2 years ago
Improve performance `Proc#parameters` method(write in Ruby)
benchmark:
```yml
prelude: |
prc = proc{|x, y=42, *other|}
lam = lambda{|x, y=42, *other|}
benchmark:
proc_no_kwarg: |
prc.parameters
proc_given_kwarg: |
prc.parameters(lambda: false)
lambda_no_kwarg: |
prc.parameters
lambda_given_kwarg: |
prc.parameters(lambda: false)
loop_count: 20000000
```
result:
```bash
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-22T10:34:00Z master 8dfe3bdf48) [x86_64-linux]
built-ruby: ruby 3.2.0dev (2022-10-22T10:34:00Z improve_prom_param.. 8dfe3bdf48) [x86_64-linux]
# Iteration per second (i/s)
| |compare-ruby|built-ruby|
|:-------------------|-----------:|---------:|
|proc_no_kwarg | 4.559M| 3.944M|
| | 1.16x| -|
|proc_given_kwarg | 2.885M| 3.652M|
| | -| 1.27x|
|lambda_no_kwarg | 4.732M| 3.800M|
| | 1.25x| -|
|lambda_given_kwarg | 2.858M| 3.603M|
| | -| 1.26x|
```
COMPARE_RUBY is `ruby 3.2.0dev (2022-10-22T10:34:00Z master 8dfe3bdf48) [x86_64-linux]`. BENCH_RUBY is ahead of `ruby 3.2.0dev (2022-10-22T10:34:00Z master 8dfe3bdf48) [x86_64-linux]`.
pull request: https://github.com/ruby/ruby/pull/6617