README in faster_require-0.8.0 vs README in faster_require-0.9.1

- old
+ new

@@ -1,10 +1,11 @@ -A little utility to make +A little utility to make load time faster, especially by making require 'xxx' -take much less time. As in much less. Well, on windows at least. And to speedup how long it takes things to load in windows, like rails apps. +take much less time. As in much less. Well, on windows at least it's faster. +It speeds up how long it takes things to load in windows, like rails apps. Well, mostly on windows--on linux it's a speedup of only 0.41 to 0.45s, or so. [1] If you've ever wondered why ruby feels slow on doze...sometimes it's just the startup time. This really helps. @@ -53,29 +54,38 @@ without: 1.37s with: 1.25s Note: in reality what we should do is fix core so that it doesn't have such awful load time in windows. There may be some inefficiency in there. For now, this is a work-around that helps. -Also it helps with SSD's even, on windows, as it avoids some cpu used at require time. +Also it helps with SSD's even, on windows, as it avoids some cpu used at require time, at least for 1.9.x +NB that installing newer versions of rubygems also seems to speedup start time (see below for how you can use them both, however, which is the best way). +In fact, 1.8.7 with newer rubygems and only very few requires seems pretty fast, even without faster_require. +Once you have any number of requires, though, you'll want faster_require. +Rails needs it, and 1.9 still needs it, though, even with a newer rubygems, +so you'll get some benefit from this library always--but don't take my word for it, +profile it and find out for yourself. + == How to use == -In general, you can either use it by installing the gem, then adding +The naive we is to use it by installing the gem, then adding + require 'rubygems' require 'faster_require' -to the top of your script. -However this doesn't speedup the loading of rubygems, so you can do this to get best performance: +to the top of some (your initial) script. +However this doesn't speedup the loading of rubygems itself (XXX is much speedup?), so you can do this to get best performance: + G:>gem which faster_require C:/installs/Ruby187/lib/ruby/gems/1.8/gems/faster_require-0.7.4/lib/faster_require.rb now before doing require rubygems in your script, do this: require 'C:/installs/Ruby187/lib/ruby/gems/1.8/gems/faster_require-0.7.4/lib/faster_require.rb' -Then rubygems load will be cached too. Faster. +Then rubygems' load will be cached too. Which is faster. Or see "installing globally" below. == How to use in Rails == One way is to install the gem, then add a @@ -105,27 +115,43 @@ If you use bundler to change bundled gems, you'll want to run the command $ faster_require --clear-cache so that it will pick up any new load paths. Also if you moves files around to new directories, you may want to do the same. As you install any new gems, it should clear the paths automatically for you. - == How to use generally/globally == You can install it to be used "always" (well, for anything that loads rubygems, at least, which is most things, via something like the following): $ gem which rubygems d:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems.rb $ gem which faster_require d:/Ruby192/lib/ruby/gems/1.9.1/gems/faster_require-0.6.0/lib/faster_require.rb -Now edit that rubygems.rb file, and add a require line to the top of it like this: +Now edit the rubygems.rb file, and add a require line to the top of it of the faster_require file, like this: +require 'd:/Ruby192/lib/ruby/gems/1.9.1/gems/faster_require-0.6.0/lib/faster_require.rb' -require 'd:/Ruby192/lib/ruby/gems/1.9.1/gems/faster_require-0.6.0/lib/faster_require.rb' +at the top of rubygems.rb file -update the path for your own, obviously. You'll also have to change that added line if +update the path to be your own, obviously. You'll also have to change that added line if you ever install a newer version of faster_require gem, or if you update your version of rubygems, as the rubygems.rb file will be wiped clean at that point. + +This will cause everything to load faster. + +== How to ignore PWD for faster_require == + +Faster_require also takes into consideration your Dir.pwd when you run it, for cacheing sake. +This means that if you run a ruby gem install script (like redcar's bin/redcar, for instance) and run it from different directories, it will always +be slow the first time you run it in each directory. +To make it be fast and basically disregard PWD, you can add global setting $faster_require_ignore_pwd_for_cache = true +and set it before requiring faster_require itself. + +So not rubygems.rb at the top would look like +$faster_require_ignore_pwd_for_cache = true +require 'd:/Ruby192/lib/ruby/gems/1.9.1/gems/faster_require-0.6.0/lib/faster_require.rb' + +And now your gem scripts will run fast regardless of where you run them from. == See also == Spork can help speedup rails tests. I "should" work well when used in conjunction with faster_require, as well. \ No newline at end of file