Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A couple of things come to mind. You do not specify what Ruby implementation you are using. Since you run Ruby 1.8.6 on Windows, I am going to assume that you are using MRI installed via the Windows One-Click Installer.</p> <p>This is kind of a worst-case scenario:</p> <ol> <li>MRI is the slowest of all the Ruby implementations</li> <li>MRI on Windows is <em>even slower</em> than MRI on Linux or OSX</li> <li>The One-Click Installer uses the pre-compiled binaries from Ruby-Lang.Org, which are compiled with Microsoft Visual C++ 6.0 from 1996, and thus are <em>even slower</em> than MRI on Windows compiled with Microsoft Visual C++ 10.0 or GCC 4.x or even GCC 3.x.</li> </ol> <p>Here's a couple of tips that you could try to improve performance:</p> <ul> <li>use the <a href="http://RubyInstaller.Org/" rel="nofollow noreferrer">RubyInstaller</a> project, which uses interpreters compiled with GCC 3.x instead of MSVC6, </li> <li>maybe recompile the interpreter yourself (it's not that hard with the Rakefiles provided by the <a href="https://GitHub.Com/OneClick/RubyInstaller/" rel="nofollow noreferrer">RubyInstaller</a> project) with GCC 4.x and/or different optimization options (RubyInstaller is compiled with moderate optimization options and for generic 386 CPUs), </li> <li>use a newer version of MRI than 1.8.6, </li> <li><p>use a different implementation of Ruby: </p> <ul> <li>YARV is significantly faster than MRI (unfortunately, it only implements Ruby 1.9, so you might have to change your code), </li> <li><a href="http://JRuby.Org/" rel="nofollow noreferrer">JRuby</a> is significantly faster than YARV in a lot of scenarios, and it implements both Ruby 1.8 and Ruby 1.9 (it also has a <code>-fast</code> commandline option, which is slightly incompatible with Ruby, but improves performance, including arithmetic performance) and </li> <li><a href="http://IronRuby.Net/" rel="nofollow noreferrer">IronRuby</a> might also be faster than YARV, depending on the workload.</li> </ul></li> </ul> <p>In the latter two cases you might want to revise your benchmarks a bit. Both eventually can compile Ruby code to native machine code, but it might take a while. JRuby for example compiles to JVM bytecode after a method has been executed 20 times and HotSpot Server compiles JVM bytecode to native machine code after it has executed 20000 times. Also, compilation itself takes time, so the program needs to run a while to gain back that cost through improved performance.</p> <p>In particular, Charles Oliver Nutter, one of the JRuby lead developers, said that depending on the workload, JRuby might take up to 5-15 seconds to ramp up to full speed. Your benchmarks are about 100x too fast (here's a sentence you don't hear every day ...).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload