Speeding up running Ruby script on Windows or Cygwin

I have a ruby ​​script that takes about 30 seconds to run. This takes a lot because it tries to load all the libraries and stuff.

When I do ruby.exe -v instantly.

I do not want to touch the original ruby ​​script, which is not written by me.

What are the tricks to speed up this process?

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

I need to do this under Windows or Cygwin.

UPDATE:

  • The scripts are rather slow on Linux / Mac; this condition does not apply to Windows.
  • This is a regular ruby ​​1.8.7 (similar speed in other ruby ​​versions)
  • The main bottleneck is loading so many libraries (I deleted unnecessary files and libraries and reduced the time to drastically, but still slow).
+4
source share
2 answers

I suppose the script uses rubygems? (If so, let's say "rubygems" is needed)

You can try to install mini-games (mini-games to install gem), and then use mini-games instead of rubigems - you need to speed things up a bit.

+1
source

Sorry, but it is not possible to compile a ruby ​​script. What is this download / activity script?

You are right, 30 seconds are quite long. Does this script make calls on the Internet or in databases that are very expensive? It's hard to believe that libraries will take so long to load

... I just noticed the comments and saw that you got to 1-4 seconds ... this is very good, especially when you go down from 30. Other comments are correct, please place the required at the top of the script

0
source

All Articles