Does Ruby 2 Load Rails Twice As Fast?
TL;DR: Ruby 2.0.0: 5s vs 1.9.3: 8s
Ruby 2! Ruby 2! I decided to try it out on an existing (Rails 3.2.12) project I'm working on. The upgrade was smooth (upgrade instructions at this gist), however I did have to pull a couple of gems (that I wasn't actively using anyway) - I love pry, not sure how debugger keeps creeping into my gemfile...
# Gemfile # binding_of_caller # debugger
Actually I deleted them, not comment them out, but whatever. On to the good stuff:
Test Setup
As I mentioned before I'm testing on a Rails 3.2.12 application, running just the model tests (since they're fast and I wanted to focus on overhead but still make the "work" non-trivial). Running on my 2.3 GHz Core i7 MacBook Pro (with SSD).
Ruby 2 (with RCov - oops)
bash-3.2$ time rspec spec/models/ ................................................................. ................................................................. ................................................................. ............................................. Finished in 4.69 seconds 240 examples, 0 failures Randomized with seed 2277 Coverage report generated for RSpec to project_path/coverage. 1346 / 2082 LOC (64.65%) covered. Coverage report Rcov style generated for RSpec to project_path/coverage/rcov real 0m12.118s user 0m10.200s sys 0m0.886s
Almost 8 seconds of Rails overhead. Ouch
Which is, whatever. But then my attention was drawn to the rcov report. I'm growing tired of this crappy rcov report that seems to slow things down and honestly doesn't provide any information on an "every time my specs run" basis. Of course, when I want to retire some technical debt, or make sure my application is "Rugged", it's a good tool. So I try skipping it.
Ruby 2
bash-3.2$ export SKIP_RCOV=true bash-3.2$ time rspec spec/models/ ................................................................. ................................................................. ................................................................. ............................................. Finished in 4.1 seconds 240 examples, 0 failures Randomized with seed 34018 real 0m9.190s user 0m8.040s sys 0m0.738s
5 seconds of Rails loading overhead
Much much better. And of course, the RCov stuff gets pulled from my Gemfile and spec_helper.rb because time is money, and I can't afford an extra 4 seconds each time I run tests.
Ruby 1.9.3-p327
bash-3.2$ time rspec spec/models/ ................................................................. ................................................................. ................................................................. ............................................. Finished in 4.11 seconds 240 examples, 0 failures Randomized with seed 62673 real 0m12.595s user 0m10.464s sys 0m1.123s
Ruby 1.9.3 is over 8 seconds of overhead
Ruby 2 was almost twice as fast. Pretty awesome, and since it "just worked" - at least for my tests (here's hoping my tests actually cover things), I'll leave it in for now.