-
Notifications
You must be signed in to change notification settings - Fork 378
Add comparison for method vs forwarded method vs delegated method #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Author
yogeshjain999
commented
Apr 9, 2021
Hey guys, any updates on this ?
Collaborator
nirvdrum
commented
Apr 9, 2021
I just tried running this locally and the benchmark doesn't work with Ruby 2.7. It looks like you need to add require 'delegate'.
@yogeshjain999
yogeshjain999
force-pushed
the
method-delegations
branch
from
April 10, 2021 09:45
927a17d to
840486b
Compare
Author
yogeshjain999
commented
Apr 10, 2021
@nirvdrum Thanks, fixed it.
It seem the difference between forwarded and delegated method has been increased in ruby >= 2.7.
Warming up -------------------------------------- method 307.381k i/100ms forwarded method 228.038k i/100ms delegated method 110.079k i/100ms Calculating ------------------------------------- method 3.103M (± 0.9%) i/s - 15.676M in 5.052459s forwarded method 2.299M (± 1.2%) i/s - 11.630M in 5.059510s delegated method 1.102M (± 0.9%) i/s - 5.614M in 5.095893s Comparison: method: 3102988.8 i/s forwarded method: 2298988.2 i/s - 1.35x (± 0.00) slower delegated method: 1101769.4 i/s - 2.82x (± 0.00) slower
krtschmr
krtschmr
approved these changes
Oct 7, 2021
@krtschmr
krtschmr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice one
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add benchmarks to understand when to define method explicitly, forward method with
def_delegatoror useSimpleDelegator.