Search code examples
windowsrubycygwinperformance

Speeding up Ruby script startup in Windows or Cygwin


I've got a ruby script which takes about 30 seconds to startup. It takes that much because it tries to load all libraries and stuff.

When I do ruby.exe -v it's instant.

I don't want to touch the original ruby script, which is not written by me.

What are the tricks to speed this process up?

  • Can I precompile it?
  • Can I precache all of these files?

I need to do this under Windows or Cygwin.

UPDATE :

  • Scripts is quite slow in Linux/Mac as well, this condition is not specific to Windows.
  • This is normal ruby 1.8.7 (similar speed in other ruby versions)
  • Main bottleneck is loading so many libraries (I removed unrequired files and libraries and decrease the time to drastically but still slow)

Solution

  • I presume the script uses rubygems? (It'll say require "rubygems" if so)

    You could try installing minigems (gem install minigems) and then use minigems instead of rubygems - should speed things up a little.