Please to announce release code-named “spooky” of fast rubygems.
Changelog:
added ‘frubygems’
as an additional require option
Synopsis:
require ‘frubygems’ # takes about 1/5th the time of doing a require
‘rubygems’
Essentially gem_prelude for 1.8
README:
A helper to dramatically speedup the time it takes to load rubygems
require ‘rubygems’ no longer has to sap valuable time from your life
inspired by a request from Yehuda K. [1] and 1.9’s fast gem_prelude.
Speed difference (windows box, lots of gem):
$ time ruby examples/require_rubygems_normal.rb
real 0m1.109s
$ time ruby examples/require_fast_start.rb
real 0m0.500s
Yea! Finally ruby script startup times that don’t spend forever just
reloading gem paths.
It acts about the same as gem_prelude (prelude is 1.9 only currently) –
adds the paths of the highest version of each
gem into your load path so they’re ready to be required.
== installation ==
git clone git://github.com/rogerdpack/faster_rubygems.git
ruby faster_rubygems/install.rb # done!
== usage ==
instead of
require ‘rubygems’
it’s either
require ‘frubygems.rb’
or
require ‘rubygems_fast.rb’
(both do the same thing, first is to save key strokes)
in your scripts.
If you were really clever I suppose you could figure out how to override
the default rubygem behavior to do this, always
For those interested, speed difference example on linux (250 gems):
$ time ruby examples/require_rubygems_normal.rb
ruby examples/require_rubygems_normal.rb 0.57s user 0.05s system 85%
cpu 0.726 total
$ time ruby examples/require_fast_start.rb
ruby examples/require_fast_start.rb 0.04s user 0.02s system 46% cpu
0.121 total
Note also that a few non conforming gems require the use of require
‘rubygems’ no matter what (they’re pretty rare,
though–you probably won’t run into them, and I’m not aware of any).
Note: you don’t need this for ruby 1.9, which already preloads via
gem_prelude, but it won’t hurt to use it in 1.9–it
defaults to a no-op, so doesn’t hurt.