Actions
Feature #19076
closedImprove performance Proc#parameters
Status:
Closed
Assignee:
-
Target version:
-
Description
Improve performance Proc#parameters
method(write in Ruby)
benchmark:
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:
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
Updated by S_H_ (Shun Hiraoka) about 2 years ago
- Subject changed from Improve performance `Proc#parameters` to Improve performance Proc#parameters
Updated by jeremyevans0 (Jeremy Evans) about 2 years ago
If I'm reading the benchmark results correctly, this is slower in the case that the keyword argument is not provided. Is that correct? If so, I don't think we should do this, because it is far more common to not provide a keyword argument when calling these methods.
Updated by S_H_ (Shun Hiraoka) about 2 years ago
Sorry, I checked benchmark and it seems to always be slower then don't pass keyword arguments
Therefore, you may close this ticket.
Updated by jeremyevans0 (Jeremy Evans) about 2 years ago
- Status changed from Open to Closed
Actions
Like1
Like0Like0Like0Like0Like0