# How fast does your Ruby run?

**URL:** <https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144>\
**Category:** Ruby\
**Created:** [September 21, 2007, 12:49am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144 "2007-09-21T00:49:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 12:49am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/1 "2007-09-21T00:49:36Z")

</div>

How fast does your Ruby run?

I got 53648 iterations per second running the following program,  
on an Intel 3.2 GHz HT, Win XP machine:

* * *

C:\> ruby calculate.rb  
55

Ruby 1.8.6 patch 0 on i386-mswin32  
It took 18.64 seconds to run. 53648 iterations per second.

* * *

n = 1\_000\_000

start\_time = Time.now

for i in 1…n  
t = (1…10).inject {|x, y| x + y }  
end

finish\_time = Time.now

p t

puts  
print "Ruby ", RUBY\_VERSION, " patch ", RUBY\_PATCHLEVEL, " on ",  
RUBY\_PLATFORM

puts  
print “It took #{finish\_time - start\_time} seconds to run.”  
print " #{(n / (finish\_time - start\_time)).to\_i} iterations per  
second.\n"

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 1:15am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/2 "2007-09-21T01:15:22Z")

</div>

SpringFlowers AutumnMoon wrote:

> How fast does your Ruby run?
> 
> I got 53648 iterations per second running the following program,  
> on an Intel 3.2 GHz HT, Win XP machine:
> 
> * * *
> 
> C:\> ruby calculate.rb  
> 55
> 
> Ruby 1.8.6 patch 0 on i386-mswin32  
> It took 18.64 seconds to run. 53648 iterations per second.

I just ate your lunch. MacPro 3ghz dual duo 2gb ram.

Ruby 1.8.2 on universal-darwin8.0  
It took 6.383342 seconds to run. 156657 iterations per second.

(I had to take out RUBY\_PATCHLEVEL, as that’s not defined, but I suspect  
I could have put a begin/rescue/end in around and STILL have eaten your  
lunch. LOLOLOLOL

Todd

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 1:35am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/3 "2007-09-21T01:35:15Z")

</div>

Todd B. wrote:

> SpringFlowers AutumnMoon wrote:
> 
> > How fast does your Ruby run?

> Ruby 1.8.2 on universal-darwin8.0  
> It took 6.383342 seconds to run. 156657 iterations per second.
> 
> (I had to take out RUBY\_PATCHLEVEL, as that’s not defined, but I suspect  
> I could have put a begin/rescue/end in around and STILL have eaten your  
> lunch. LOLOLOLOL

Ruby 1.8.2 on universal-darwin8.0  
It took 5.920011 seconds to run. 168918 iterations per second.

I changed the scope of x & y and eeked out some more speed.

x, y = nil  
for i in 1…n  
t = (1…10).inject {|x, y| x + y }  
end

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 1:52am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/4 "2007-09-21T01:52:09Z")

</div>

On 9/20/07, SpringFlowers AutumnMoon [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> How fast does your Ruby run?
> 
> I got 53648 iterations per second running the following program,  
> on an Intel 3.2 GHz HT, Win XP machine:

As you are seeing, ruby 1.8.x is painfully slow on Windows. =(

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 1:55am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/5 "2007-09-21T01:55:09Z")

</div>

On Sep 20, 2007, at 16:15, Todd B. wrote:

> > 
> 
> suspect  
> I could have put a begin/rescue/end in around and STILL have eaten  
> your  
> lunch. LOLOLOLOL

pwn!

$ pbpaste | ruby19  
55

Ruby 1.9.0 patch 0 on i686-darwin8.10.1  
It took 2.838405 seconds to run. 352310 iterations per  
second.

2.16GHz Core 2 Duo

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 1:22am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/6 "2007-09-21T01:22:49Z")

</div>

Todd B. wrote:

> SpringFlowers AutumnMoon wrote:
> 
> > How fast does your Ruby run?
> > 
> > I got 53648 iterations per second running the following program,  
> > on an Intel 3.2 GHz HT, Win XP machine:
> > 
> > * * *
> > 
> > C:\> ruby calculate.rb  
> > 55
> > 
> > Ruby 1.8.6 patch 0 on i386-mswin32  
> > It took 18.64 seconds to run. 53648 iterations per second.
> 
> I just ate your lunch. MacPro 3ghz dual duo 2gb ram.
> 
> Ruby 1.8.2 on universal-darwin8.0  
> It took 6.383342 seconds to run. 156657 iterations per second.
> 
> (I had to take out RUBY\_PATCHLEVEL, as that’s not defined, but I suspect  
> I could have put a begin/rescue/end in around and STILL have eaten your  
> lunch. LOLOLOLOL
> 
> Todd

HAHAH. I love it! awesome.

time for my sad reality. I think you just ate my lunch too ☹

C:\>ruby calculate.rb  
55

Ruby 1.8.6 patch 0 on i386-mswin32  
It took 22.359 seconds to run. 44724 iterations per  
second.

Intel 2.8 GHz 1.5Gb RAM WinXP

~Jeremy

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 2:16am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/7 "2007-09-21T02:16:11Z")

</div>

SpringFlowers AutumnMoon wrote:

> Ruby 1.8.6 patch 0 on i386-mswin32  
> end  
> print “It took #{finish\_time - start\_time} seconds to run.”  
> print " #{(n / (finish\_time - start\_time)).to\_i} iterations per  
> second.\n"

amd athlon 2500+XP processor (1883 MHz) 1GB ram

-------------cygwin ruby 1.8.6----------  
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-cygwin]  
yes, that’s on cygwin.  
$ ruby howquick.rb  
55

Ruby 1.8.6 patch 0 on i386-cygwin  
It took 15.816 seconds to run. 63227 iterations per  
second.

-------------native ruby same box 1.8.5----------  
C:\ruby\bin\>ruby c:\cygwin\home\rthompso\howquick.rb  
55

c:/cygwin/home/rthompso/howquick.rb:14: uninitialized constant  
RUBY\_PATCHLEVEL (  
NameError)  
removed pathlevel …  
C:\ruby\bin\>ruby c:\cygwin\home\rthompso\howquick.rb  
55

Ruby 1.8.5 on i386-mswin32  
It took 30.782 seconds to run. 32486 iterations per  
second.

-------------native ruby same box updated to 1.8.6----------  
C:\ruby\bin\>ruby c:\cygwin\home\rthompso\howquick.rb  
55

Ruby 1.8.6 patch 0 on i386-mswin32  
It took 24.453 seconds to run. 40894 iterations per  
second.

------------ruby 1.8.5 linux core2 duo gentoo 2gb RAM-------  
rthompso@raker ~ $ ruby howquick.rb  
55

Ruby 1.8.5 patch 2 on i686-linux  
It took 11.779449 seconds to run. 84893 iterations per  
second.

------------updated ruby 1.8.6 same linux core2 duo 2gb RAM—

rthompso@raker ~ $ ruby howquick.rb  
55

Ruby 1.8.6 patch 36 on i686-linux  
It took 9.702104 seconds to run. 103070 iterations per  
second.

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 2:14am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/8 "2007-09-21T02:14:11Z")

</div>

On Fri, Sep 21, 2007 at 08:15:22AM +0900, Todd B. wrote:

> > 
> 
> I could have put a begin/rescue/end in around and STILL have eaten your  
> lunch. LOLOLOLOL

FreeBSD 6.2-RELEASE on a Pentium M/Centrino 1.7GHz Thinkpad R52:

> ruby calculate.rb  
> 55

Ruby 1.8.6 patch 0 on i386-freebsd6  
It took 16.125757 seconds to run. 62012 iterations per  
second.

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 2:18am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/9 "2007-09-21T02:18:11Z")

</div>

On Fri, Sep 21, 2007 at 08:35:16AM +0900, Todd B. wrote:

> > 
> 
> Ruby 1.8.2 on universal-darwin8.0  
> It took 5.920011 seconds to run. 168918 iterations per second.
> 
> I changed the scope of x & y and eeked out some more speed.
> 
> x, y = nil  
> for i in 1…n  
> t = (1…10).inject {|x, y| x + y }  
> end

That cut almost three full seconds off my time – down to 13.829852  
seconds to run, at 72307 iterations per second. Obviously, you’re still  
kicking the crap out of my poor little Pentium M.

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 2:20am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/10 "2007-09-21T02:20:13Z")

</div>

Reid T. wrote:

> > t = (1…10).inject {|x, y| x + y }  
> > puts  
> > 55  
> > c:/cygwin/home/rthompso/howquick.rb:14: uninitialized constant  
> > -------------native ruby same box updated to 1.8.6----------
> 
> It took 9.702104 seconds to run. 103070 iterations per  
> second.  
> forgot the processor speed for the linux core2 duo  
> model name : Intel® Core™2 CPU 6320 @ 1.86GHz

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 2:39am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/11 "2007-09-21T02:39:51Z")

</div>

Eric H. wrote:

> pwn!
> 
> $ pbpaste | ruby19  
> 55
> 
> Ruby 1.9.0 patch 0 on i686-darwin8.10.1  
> It took 2.838405 seconds to run. 352310 iterations per  
> second.
> 
> 2.16GHz Core 2 Duo

OOOOUCH!!! Ruby 1.9.0 is HOT!

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 4:35am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/12 "2007-09-21T04:35:29Z")

</div>

On Sep 20, 6:49 pm, SpringFlowers AutumnMoon  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> How fast does your Ruby run?
> 
> I got 53648 iterations per second running the following program,  
> on an Intel 3.2 GHz HT, Win XP machine:

Dual Core AMD Opteron 270 2GHz  
Ruby 1.8.5 on i486-linux  
It took 19.373381 seconds to run. 51617 iterations per second.

Not too fast, but I do have a couple of Western Digital (WD1500ADFD)  
drives, so the I/O screams 🙂

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 7:51am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/13 "2007-09-21T07:51:46Z")

</div>

Charles Oliver N. wrote:

> It took 10.262067 seconds to run. 97446 iterations per second.  
> I also tried Ruby 1.9 and Rubinius, but Rubinius crashed.

Ruby 1.9.0 patch 0 on i686-darwin8.10.1  
It took 3.299607 seconds to run. 303066 iterations per second.

- Charlie

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 7:47am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/14 "2007-09-21T07:47:45Z")

</div>

Todd B. wrote:

> > Ruby 1.8.6 patch 0 on i386-mswin32  
> > It took 18.64 seconds to run. 53648 iterations per second.
> 
> I just ate your lunch. MacPro 3ghz dual duo 2gb ram.
> 
> Ruby 1.8.2 on universal-darwin8.0  
> It took 6.383342 seconds to run. 156657 iterations per second.

MacBook Pro 2.1G. I tried both Ruby and JRuby.

JRuby:

Ruby 1.8.5 patch 3876 on java  
It took 8.022 seconds to run. 124657 iterations per second.

Ruby:

Ruby 1.8.6 patch 0 on i686-darwin8.9.1  
It took 10.262067 seconds to run. 97446 iterations per second.

- Charlie

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 8:12am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/15 "2007-09-21T08:12:47Z")

</div>

On 9/21/07, Charles Oliver N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> Wow my work machine is really bad  
> A 2.6Ghz on XP with 512M

55

Ruby 1.8.6 patch 0 on i386-mswin32  
It took 35.844 seconds to run. 27898 iterations per  
second.

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 11:16am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/16 "2007-09-21T11:16:11Z")

</div>

On Sep 21, 10:49 am, SpringFlowers AutumnMoon  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## Ruby 1.8.6 patch 0 on i386-mswin32 end print “It took #{finish\_time - start\_time} seconds to run.” print " #{(n / (finish\_time - start\_time)).to\_i} iterations per second.\n"
> 
> Posted viahttp://www.ruby-forum.com/.

AMD 2.8 GHz Ubuntu 7.04 2 GB RAM  
geoff@geoff-laptop:~/prog/ruby$ ruby calculate.rb  
55

Ruby 1.8.6 patch 0 on i686-linux  
It took 13.012441 seconds to run. 76849 iterations per  
second.

And then with the addition of  
x, y = nil

geoff@geoff-laptop:~/prog/ruby$ ruby calculate.rb  
55

Ruby 1.8.6 patch 0 on i686-linux  
It took 12.135616 seconds to run. 82402 iterations per  
second.

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 11:22am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/17 "2007-09-21T11:22:12Z")

</div>

SpringFlowers AutumnMoon wrote:

> How fast does your Ruby run?
> 
> I got 53648 iterations per second running the following program,  
> on an Intel 3.2 GHz HT, Win XP machine:

Here’s something interesting. The processor is Intel T7200 @ 2.00GHz,  
Linux Ubuntu.

1. With ruby 1.8.5. which comes packaged with Ubuntu:

2. With ruby 1.9.0 (2006-06-08) which comes packaged in Ubuntu:

3. With ruby 1.8.6 compiled from sources on the machine:

Obviously, the target instruction set matters quite a lot. I think I’ll  
be compiling my own ruby from now on. 🙂

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 11:23am UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/18 "2007-09-21T11:23:12Z")

</div>

Seems like a pretty silly test, but okay…

$ unset RUBYOPT && ruby1.8 /home/gga/bin/ruby/speed\_test.rb && ./ruby /  
home/gga/bin/ruby/speed\_test.rb && echo && uname -a

Ruby 1.8.5 on x86\_64-linux  
It took 14.754958 seconds to run. 67773 iterations per second.

Ruby 1.9.0 on x86\_64-linux  
It took 2.558372 seconds to run. 390873 iterations per second.

Linux aura1 2.6.17-10-generic #2 SMP Tue Dec 5 21:16:35 UTC 2006  
x86\_64 GNU/Linux  
AMD 4400 2CPUs.

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 12:16pm UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/19 "2007-09-21T12:16:22Z")

</div>

Le 21 septembre à 00:49, SpringFlowers AutumnMoon a écrit :

> How fast does your Ruby run?

Ok. Since I can’t possibly win this DSW, I’ll try this on my slowest  
machines… 🙂

- AMD Athlon 1.4GHz (quite busy server) :

Ruby 1.8.6 patch 0 on i386-freebsd6  
It took 42.070099 seconds to run. 23769 iterations per second.

Aaand…

- PIII 500MHz (diskless workstation with very limited RAM - especially  
raised from the dead just for you, people !) :

Ruby 1.8.4 patch ? on i386-freebsd6  
It took 202.375195 seconds to run. 4941 iterations per second.

(Wooot !)

BTW, on the other direction :

- AMD Opteron 244 1.8GHz :

Ruby 1.8.6 patch 0 on amd64-freebsd6  
It took 12.838229 seconds to run. 77892 iterations per second.

Fred

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 21, 2007, 2:26pm UTC](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144/20 "2007-09-21T14:26:47Z")

</div>

2007/9/21, SpringFlowers AutumnMoon [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> How fast does your Ruby run?

Hi, here are my results:

\*\*\*\* Ubuntu GNU/Linux on a Thinkpad R52 (Intel Celeron 1.4 Ghz)

$ ruby calculate.rb  
55

Ruby 1.8.5 on i486-linux  
It took 20.216099 seconds to run. 49465 iterations per  
second.

\*\*\*\* MacBook (intel dual core)

$ ruby calculate.rb  
55

Ruby 1.8.2 on universal-darwin8.0  
It took 11.872489 seconds to run. 84228 iterations per  
second.

[Next page](https://www.ruby-forum.com/t/how-fast-does-your-ruby-run/115144.md?page=2)
