Well, I've been getting rid of my Factory Girl for my controllers at least
and I run 280 tests in about 1.5 seconds. To me, this is worth it as before
it took 40-50 seconds. This is too much of a speed improvement to ignore I
think.

I am at a loss as to why Factory_girl takes so many cpu cycles to create a
few objects per test. I have benchmarked a simple call to
Factory.create(:user), and it takes .14 seconds to run.

Even if you use Factory.build() though and it doesn't hit the database, it
is STILL slow. I am at a loss as to how factory_girl cannot come close to
the performance of manually instantiating the object yourself. Why is it so
much slower? I'd have to look at their source code to know for sure.

Honestly though, I have removed factory_girl completely from my controller
tests and I am so thrilled. I have not really lost anything in terms of
expressiveness.

Sure, I have to add a pieces of data to make render_views comply, but it's
not much. It is a *very small* price to pay for this much performance gain.

Ken


On Wed, May 25, 2011 at 5:45 PM, Justin Ko <jko...@gmail.com> wrote:

>
>
> On Wed, May 25, 2011 at 1:00 PM, Ken Egervari <ken.egerv...@gmail.com>wrote:
>
>> I am using factory_girl, and I have discovered that it is chiefly
>> responsible for making my tests run slow.
>>
>> I have posted a question about this on Stack Overflow:
>>
>>
>> http://stackoverflow.com/questions/6128476/how-can-i-get-factory-girl-to-never-hit-the-database-if-i-am-calling-factory-buil
>>
>> Anyway, I was curious what you guys use to create Factories?
>>
>> 1. Do you put up with Factory_girl?
>> 2. Did you configure Factory_girl differently to make it run faster?
>> 3. Do you use something else? May I ask what?
>>
>> Thanks!
>>
>> Ken
>>
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
>
>
> In Rails land, tests are "slow" because of the database. Sorry, but there
> is just no way around it. Sure, you could mock everything out, but we all
> know the implications of doing that...
>
> rspec-core has 691 examples and takes 2 seconds to run. That would be
> amazing if we could have that for our Rails apps.
>
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to