Skip to content
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

instance_exec is much slower than define_method to invoke closures #851

Closed
colinsurprenant opened this issue Jul 3, 2013 · 1 comment
Closed

Comments

@colinsurprenant
Copy link
Contributor

as per discussion with @headius https://twitter.com/headius/status/349951285295980544 I am reporting this performance oddity.

I benchmarked 3 ways for invoking a closure on an object instance using instance_exec, define_singleton_method and define_method and found out that using define_method is ~10x faster. See https://gist.github.com/colinsurprenant/5869685

AFAIK these 3 ways of invoking a closure should be semantically equivalent?! as such there might be room for optimization on instance_exec?

Note that results are similar with MRI 2.0.0p195.

@kares
Copy link
Member

kares commented May 22, 2017

this is expected to be no longer relevant with 9K's block JIT-ing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants