[rspec-users] Spec/Test Speed
M. Edward (Ed) Borasky
znmeb at cesmail.net
Thu Oct 4 00:15:28 EDT 2007
Scott Taylor wrote:
> Just wanted to pick some smart people about this topic: What are you
> guys doing to increase the speed of your specs?
>
> I'm a big fan of autotest, but right now my current project has 438
> specs (for rails). Most of them are in the model, and for all of
> them we are hitting the database (they are more functional specs than
> unit-tests). The whole suite takes 112 seconds (meaning the red to
> green cycle leaves me learning how to juggle, just like Jim Weirich
> with make). Any recommendations, short of mocking/stubbing to get
> around this? Some of the suggestions I've heard are:
>
> - In Memory Database w/ Sqlite. As far as I know, no one has gotten
> this to work (with rspec, at least)
> - Using faster hardware. I don't have the budget right now for a
> better machine. One interesting idea is this one: http://
> www.dcmanges.com/blog/deep-test-preview, although as far as I know,
> it doesn't work for rspec.
> - Only running specs per file, and using continous integration to do
> the rest. Right now this isn't an option for testing my User model,
> which has 92 examples, and takes 20 seconds. Also, I'd really rather
> not commit before I know the whole test suite passes
> - Other ideas?
>
> Scott
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
1. Use the Ruby profiler to see where it's spending its time.
2. Recompile the Ruby interpreter with full optimization if you haven't
already. Assuming you're on a platform supported by gcc, download the
Ruby source and type
export CFLAGS='-O3 -march=<whatever>'
before the "./configure". <whatever> is your chip architecture, for
example "pentium3", "pentium4", "athlon-xp", ...
If your test suite and application are fully open source and you don't
mind someone playing with it, I'm collecting benchmark suites for the
Ruby interpreter and would love to have a nice heavy "rspec" run as an
example of real-world Ruby usage. Contact me off-list if you're
interested, or if you want me to show you how to profile the Ruby
interpreter itself on your test case.
More information about the rspec-users
mailing list