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

Consider optimizing trivial case statements #2

Open
yorickpeterse opened this issue Feb 17, 2016 · 0 comments
Open

Consider optimizing trivial case statements #2

yorickpeterse opened this issue Feb 17, 2016 · 0 comments

Comments

@yorickpeterse
Copy link
Contributor

Original issue: rubinius/rubinius#3620

Copied here for ease of reading:


Hello,

MRI adopts "jump table"-like optimization for case-when statement if all clauses have trivial immediate values such as Integer and Symbol. How about implementing this optimization in Rubinius?

100000.times do
  case 1000
  when 0
  when 1
  when 2
  ...
  when 999
  end
end
$ time ruby -v t.rb
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]

real    0m0.082s
user    0m0.068s
sys     0m0.012s
# time ruby -v t.rb
rubinius 3.14 (2.2.2 a7ba16db 2016-01-28 3.4.2 JI) [x86_64-linux-gnu]

real    0m2.311s
user    0m2.240s
sys     0m0.064s

(I'm using rubinius/docker.)

Thank you for your consideration,

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

No branches or pull requests

1 participant