Skip to content

Commit 71006ef

Browse files
author
David Padilla
committed
Ruby benchmarks post
1 parent 8b9301b commit 71006ef

File tree

1 file changed

+162
-0
lines changed

1 file changed

+162
-0
lines changed
+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
---
2+
layout: post
3+
title: Ruby benchmarks
4+
author: David Padilla
5+
6+
avatar: d32b52ec6403614b1adf3e648cbbe584
7+
---
8+
9+
I recently started a new client project. Lucky me, [Rails 3.1 has just
10+
been released](http://weblog.rubyonrails.org/2011/8/31/rails-3-1-0-has-been-released)
11+
so, it means I'll get to learn a bunch of things while
12+
building it, you know, the fancy [asset pipeline](http://edgeguides.rubyonrails.org/asset_pipeline.html)
13+
stuff everyone's talking about and so on.
14+
15+
I wrote a couple of rspec specs and cucumber features, made them pass, and
16+
while I was about to start now features, decided to stop to check the
17+
current state of all the different rubies to try them and pick the
18+
faster one, at least for development.
19+
20+
Well, I was already using *MRI 1.9.2*, so, for research purposes
21+
I proceeded to install *MRI 1.9.3-preview*, *Rubinus 1.2.5dev*, *REE-1.8.7* and
22+
*jRuby 1.6.3*. (Thank you [RVM](http://beginrescueend.com/) for making this as
23+
easy as possible).
24+
25+
Now, so far, my app has 4 rspec specs and 3 cucumber scenarios, but
26+
even so, I came up with interesting time results.
27+
28+
Below the results of running *time rake* for each
29+
implementation.tnueotnuo
30+
31+
## MRI 1.9.2
32+
33+
{% highlight bash %}
34+
35+
# Rspec
36+
Finished in 0.13588 seconds
37+
4 examples, 0 failures
38+
39+
# Cucumber
40+
3 scenarios (3 passed)
41+
10 steps (10 passed)
42+
0m0.756s
43+
44+
# Time
45+
real 0m24.259s
46+
user 0m20.752s
47+
sys 0m2.530s
48+
49+
{% endhighlight %}
50+
51+
## MRI 1.9.3-preview
52+
53+
{% highlight bash %}
54+
# Rspec
55+
Finished in 0.05074 seconds
56+
4 examples, 0 failures
57+
58+
# Cucumber
59+
3 scenarios (3 passed)
60+
10 steps (10 passed)
61+
0m0.379s
62+
63+
# Time
64+
real 0m13.354s
65+
user 0m10.120s
66+
sys 0m1.546s
67+
68+
{% endhighlight %}
69+
70+
## jRuby
71+
72+
{% highlight bash %}
73+
74+
# RSpec
75+
Finished in 0.186 seconds
76+
4 examples, 0 failures
77+
78+
# Cucumber
79+
3 scenarios (3 passed)
80+
10 steps (10 passed)
81+
0m2.141s
82+
83+
# Time
84+
real 1m3.823s
85+
user 2m9.875s
86+
sys 0m7.005s
87+
88+
{% endhighlight %}
89+
90+
## Rubinus
91+
92+
{% highlight bash %}
93+
94+
# RSpec
95+
Finished in 0.27061 seconds
96+
4 examples, 0 failures
97+
98+
# Cucumber
99+
3 scenarios (3 passed)
100+
10 steps (10 passed)
101+
0m2.011s
102+
103+
# Time
104+
real 0m47.328s
105+
user 1m1.049s
106+
sys 0m2.938s
107+
108+
{% endhighlight %}
109+
110+
## REE
111+
112+
Note that I used the following environment variables for this one:
113+
114+
{% highlight bash %}
115+
RUBY_GC_MALLOC_LIMIT="50000000"
116+
RUBY_HEAP_MIN_SLOTS="500000"
117+
RUBY_HEAP_SLOTS_GROWTH_FACTOR="1"
118+
RUBY_HEAP_SLOTS_INCREMENT="250000"
119+
{% endhighlight %}
120+
121+
To understand how this affects its performance, check out [this post](http://blog.crowdint.com/2010/12/07/improving-your-dev-life-with-ree.html)
122+
123+
{% highlight bash %}
124+
# RSpec
125+
Finished in 0.05163 seconds
126+
4 examples, 0 failures
127+
128+
# Cucumber
129+
3 scenarios (3 passed)
130+
10 steps (10 passed)
131+
0m0.277s
132+
133+
# Time
134+
real 0m10.769s
135+
user 0m7.519s
136+
sys 0m2.106s
137+
{% endhighlight %}
138+
139+
## Conclusion
140+
141+
It looks like there's huge speed improvements from 1.9.2 to 1.9.3. It took
142+
24 seconds on 1.9.2 and 12 on 1.9.3, that's a lot of speed boost!
143+
144+
JRuby, at 1 minute where the other rubies took seconds is light years
145+
behind them, though, I might be doing something wrong. I really have no practical
146+
experience with it and I just benchmarked it out of the box.
147+
148+
Rubinus felt kind of slow too, but, I consider it to be
149+
work in progress, or at least haven't heard of production apps running
150+
on it yet, which doesn't necesarily mean there aren't any. I'd actually
151+
love to use it on production for a few weeks when we launch this app
152+
just to see how it behaves in real life.
153+
154+
And last but not least, a properly configured REE kicks butt. No surprise there, we've been using it
155+
on another app on production for a year now with good performance and no
156+
problems at all so far.
157+
158+
So, there it is. I realize it is a small benchmark, but perhaps I can
159+
revisit it when we have more specs and more features to see if that
160+
changes how the rubies behave.
161+
162+
Cheers!

0 commit comments

Comments
 (0)