# Slow test suite with Ruby 1.9.2 and Rspec 2.5

**URL:** <https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173>\
**Category:** RSpec\
**Created:** [April 24, 2011, 10:37pm UTC](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173 "2011-04-24T22:37:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 24, 2011, 10:37pm UTC](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173/1 "2011-04-24T22:37:26Z")

</div>

Hi, I’ve started a Rails 3 project using Ruby 1.9.2 and Rspec 2 and my  
test suite is now growing and I’m not happy with the amount of time it  
is tooking to run. I did a benchmark of it with Ruby Enterprise  
Edition 1.8.7 2011.03 and it ran much more faster(5x) than Ruby 1.9.2.

Is it expected or there is something I’m missing? To see the results,  
Gemfile and spec\_helper.rb please check the gist

> <https://gist.github.com/alissonsales/939699>
>
> There are more than three files. show original

Any help or tips are very appreciated.

Thanks,  
Alisson S.

---

<div class="post-metadata">

**Author:** ![Alisson\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@Alisson\_S](https://www.ruby-forum.com/u/Alisson_S)\
**Post date:** [April 24, 2011, 10:58pm UTC](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173/2 "2011-04-24T22:58:28Z")

</div>

On Apr 24, 2011, at 3:24 PM, Alisson S. wrote:

> Thanks,  
> Alisson S.

rspec runs its own specs faster on 1.9.2 than on 1.8.7:

> <https://gist.github.com/dchelimsky/939865>

Which version of rails are you using, and what other gems are in your  
Gemfile?

---

<div class="post-metadata">

**Author:** ![Alisson\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@Alisson\_S](https://www.ruby-forum.com/u/Alisson_S)\
**Post date:** [April 24, 2011, 11:17pm UTC](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173/3 "2011-04-24T23:17:36Z")

</div>

On Sun, Apr 24, 2011 at 5:44 PM, David C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > Any help or tips are very appreciated.
> > 
> > Thanks,  
> > Alisson S.
> 
> rspec runs its own specs faster on 1.9.2 than on 1.8.7:  
> [1.8.7.sh · GitHub](https://gist.github.com/939865)

Cool.

> Which version of rails are you using, and what other gems are in your Gemfile?

Rails 3.0.5, the complete Gemfile is on the gist

> <https://gist.github.com/alissonsales/939699>
>
> There are more than three files. show original

I think the other gems that may be affecting the speed are  
factory\_girl\_rails and shoulda-matchers but in the ruby 1.8.7 the  
result is so good that I’m wondering if the problem is a specific gem.

---

<div class="post-metadata">

**Author:** ![Alisson\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@Alisson\_S](https://www.ruby-forum.com/u/Alisson_S)\
**Post date:** [April 24, 2011, 11:33pm UTC](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173/4 "2011-04-24T23:33:41Z")

</div>

Are you perhaps seeing [http://is.gd/6aINHC](http://is.gd/6aINHC) ? We’ve moved several Rails  
projects to 1.9.2 over the last few months and we’ve found our builds  
running slower on all (we use RSpec too).

Cheers,  
Sidu.  
[http://c42.in](http://c42.in)

> **[Sidu Ponnappa on about.me](https://about.me/ponnappa)**
>
> I use about.me to show people what matters most to me.

---

<div class="post-metadata">

**Author:** ![Alisson\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@Alisson\_S](https://www.ruby-forum.com/u/Alisson_S)\
**Post date:** [April 25, 2011, 12:34am UTC](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173/5 "2011-04-25T00:34:13Z")

</div>

On Sun, Apr 24, 2011 at 6:23 PM, Sidu P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Are you perhaps seeing [http://is.gd/6aINHC](http://is.gd/6aINHC) ? We’ve moved several Rails  
> projects to 1.9.2 over the last few months and we’ve found our builds  
> running slower on all (we use RSpec too).

I’m not sure if the problem is the startup time. Does the startup time  
affects results of rspec --profile?

See the results of $ rspec spec/models/user\_spec.rb -p here

> <https://gist.github.com/alissonsales/939699>
>
> There are more than three files. show original

---

<div class="post-metadata">

**Author:** ![Alisson\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@Alisson\_S](https://www.ruby-forum.com/u/Alisson_S)\
**Post date:** [April 24, 2011, 11:34pm UTC](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173/6 "2011-04-24T23:34:55Z")

</div>

Oh, and it should be sorted in 1.9.3:  
[http://redmine.ruby-lang.org/issues/show/3924](http://redmine.ruby-lang.org/issues/show/3924)

Note that this only impacts startup times - your app should still run  
faster on 1.9.2.

Best,  
Sidu.  
[http://c42.in](http://c42.in)

> **[Sidu Ponnappa on about.me](https://about.me/ponnappa)**
>
> I use about.me to show people what matters most to me.

---

<div class="post-metadata">

**Author:** ![Alisson\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@Alisson\_S](https://www.ruby-forum.com/u/Alisson_S)\
**Post date:** [April 25, 2011, 2:16am UTC](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173/7 "2011-04-25T02:16:14Z")

</div>

Unfortunately I don’t have a Rails project handy that builds on both  
1.8 and 1.9, but here are the results for a pure Ruby project:

> <https://gist.github.com/kaiwren/939981>

As you can see, the build times are nearly identical across 1.8.7,  
REE, 1.9.2 and 1.9.3-dev (I’m using RSpec 2.6.0.rc2).

Are you seeing the build slow down in direct correlation to the number  
of tests you’re running? What I’ve seen is that the delay is constant  
and a function of the number of files being required and not the  
number of tests, so the more tests you have, the closer the build  
times should be on 1.8.7 and 1.9.2.

Of course, this can make running a single spec on 1.9.2 irritatingly  
slow - one of the projects at my workplace that has a largish codebase  
had to start using spork after upgrading to 1.9.2 because what used to  
be an acceptable delay to run a single spec on 1.8.7 became excessive  
on 1.9.2.

Cheers,  
Sidu.  
[http://c42.in](http://c42.in)

> **[Sidu Ponnappa on about.me](https://about.me/ponnappa)**
>
> I use about.me to show people what matters most to me.

---

<div class="post-metadata">

**Author:** ![Alisson\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@Alisson\_S](https://www.ruby-forum.com/u/Alisson_S)\
**Post date:** [April 25, 2011, 2:42am UTC](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173/8 "2011-04-25T02:42:05Z")

</div>

Em 24-04-2011 19:22, Alisson S. escreveu:

> On Sun, Apr 24, 2011 at 6:23 PM, Sidu P.[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Are you perhaps seeing [http://is.gd/6aINHC](http://is.gd/6aINHC) ? We’ve moved several Rails  
> > projects to 1.9.2 over the last few months and we’ve found our builds  
> > running slower on all (we use RSpec too).  
> > I’m not sure if the problem is the startup time. Does the startup time  
> > affects results of rspec --profile?
> 
> See the results of $ rspec spec/models/user\_spec.rb -p here  
> [Test suite benchmark · GitHub](https://gist.github.com/939699#file__results_profile_user_spec_)

Yes, I agree with you. It probably is some issue related to some gem  
that behaves differently in Ruby 1.8 and 1.9…

That is why I miss a real good profiler tool, like that of Google Chrome  
for profiling Javascript. We discussed about this recently and David  
suggested trying out ruby-prof or Rubinius:

[http://www.ruby-forum.com/topic/1511936](http://www.ruby-forum.com/topic/1511936)

You could try the Graphic profile of ruby-prof and it might help you  
identifying which part is slower on each implementation so that you  
could identify what is the culprit gem, if that is the case.

For speeding up your startup time you can try spork. It helped a lot for  
me.

Good luck,

Rodrigo.

---

<div class="post-metadata">

**Author:** ![Alisson\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@Alisson\_S](https://www.ruby-forum.com/u/Alisson_S)\
**Post date:** [April 25, 2011, 4:00pm UTC](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173/9 "2011-04-25T16:00:15Z")

</div>

Great work! Thanks for following up.

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![Alisson\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@Alisson\_S](https://www.ruby-forum.com/u/Alisson_S)\
**Post date:** [April 25, 2011, 3:52pm UTC](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173/10 "2011-04-25T15:52:13Z")

</div>

I’ve found the problem. The gem meta\_where  
([GitHub - activerecord-hackery/meta\_where: ActiveRecord 3 query syntax on steroids. Not currently maintained.](https://github.com/ernie/meta_where)) is doing something wrong in ruby  
1.9.2, just removing it from my Gemfile and my suite is running fast  
again(6 seconds).

Thank you guys, I’ll open a issue on the meta\_where project.

On Sun, Apr 24, 2011 at 8:37 PM, Rodrigo Rosenfeld R.

---

<div class="post-metadata">

**Author:** ![Alisson\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@Alisson\_S](https://www.ruby-forum.com/u/Alisson_S)\
**Post date:** [April 27, 2011, 11:46pm UTC](https://www.ruby-forum.com/t/slow-test-suite-with-ruby-1-9-2-and-rspec-2-5/206173/11 "2011-04-27T23:46:57Z")

</div>

On Apr 25, 9:19am, Alisson S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ve found the problem. The gem meta\_where  
> ([GitHub - activerecord-hackery/meta\_where: ActiveRecord 3 query syntax on steroids. Not currently maintained.](https://github.com/ernie/meta_where)) is doing something wrong in ruby  
> 1.9.2, just removing it from my Gemfile and my suite is running fast  
> again(6 seconds).
> 
> Thank you guys, I’ll open a issue on the meta\_where project.

I’d very much appreciate any pointers as to what I might be “doing  
wrong” that only affects RSpec under 1.9.2. I’m at a loss, offhand,  
especially since regular application performance doesn’t seem to be  
adversely affected.

Squeel is also affected, apparently, and it uses RSpec for testing  
internally, running 672 examples in under 4 seconds. Maybe it’s  
something that only occurs when being tested inside a Rails app  
directly?

If anyone has any information, or a sample app/tests that clearly  
demonstrate the issue, it’d be much appreciated.
