Hi,
I noticed recently that require ‘rspec’ on my machine was taking close
to half a second. That’s not a huge amount of time, but it is still
the single slowest part of my test suite.
It boils down to Ruby 1.9’s rather slow require. I’m using 1.9.3, but
I’d still like to shave off some of the require time.
As an experiment, I went into rspec-core and rspec-expectations (the
two biggest offenders) and replaced all require calls with
require_relative. The benefits are actually quite impressive:
rspec-core:
before: 0.16s
after: 0.10s
rspec-expectations:
before: 0.16s
after: 0.05s
Applying this to rspec-mocks also, my total require time for ‘rspec’
has gone from 0.5s to 0.21s.
These are just quick a nasty timings, but there’s obviously some win to
be had.
Would David, or the RSpec developers in general accept a patch to use
require_relative if 1.9 is detected? Are there scenarios under which
require_relative would not be possible?
Cheers
Ian