[rspec-users] Slow Focus tags

David Chelimsky dchelimsky at gmail.com
Wed Jun 6 11:50:13 UTC 2012


On Wed, Jun 6, 2012 at 6:38 AM, Rainer Kuhn <rainer at incutio.com> wrote:
> I have started with a blank spec_helper and I'm seeing lots of improvements
> regarding the focus tag. Not the 12sec load time however. Let me do some
> legwork first and I present you with the results in a couple of hours.
> Tomorrow perhaps since I have a couple of hours of urgent dev work my list.
>
> My current spec_helper is a huge mess copy pasted from multiple sources over
> a period of 4 months. I'm really not proud of it especially since I'm using
> spec since 2008. Read it and weep:
> https://gist.github.com/2881400

There's a lot there. Redis, fog, all the macros modules. Any of them
could be contributing.

> On Wed, Jun 6, 2012 at 12:24 PM, David Chelimsky <dchelimsky at gmail.com>
> wrote:
>>
>> On Wed, Jun 6, 2012 at 5:14 AM, Rainer Kuhn <rainer at incutio.com> wrote:
>> > [This is my third and final attempt to post to this group, first 2 were
>> > with
>> > google groups]
>>
>> The google group is a mirror of the rspec-users list, but for that to
>> work you actually have to post to the rspec-users list, not the google
>> group. We're considering retiring that list and only using the google
>> group, at which point you'd be able to post directly to the google
>> group.
>>
>> > I noticed that focusing a single spec takes ages to run. We commonly use
>> > that, often in combination with guard to speed up our spec runs. I admit
>> > that the overall performance of our specs is bad, since we ditched
>> > mocking
>> > entirely and went with semi-integration specs on all levels. But this
>> > practice has served us very well on picking up failures.
>> >
>> > All runs on a single spec with focus: true that only tests (2 +
>> > 2).should ==
>> > 4, among 700 other specs.
>> > Any ideas how to profile or even fix that?
>> >
>> > # What I want to get:
>> > $ time rspec spec/models/user_spec.rb:5
>> > Finished in 1.41 seconds 1 example, 0 failures
>> > real 0m13.768s
>> > user 0m11.269s
>> > sys 0m1.692s
>>
>> Wow. This is _not_ what I'd want to get. Nearly 14 secs to run a
>> single example sounds like you're suffering some serious startup time.
>> What version of rspec, ruby, rails, etc are you running?
>>
>> > # What I get using the focus tag:
>> > $ time rake spec
>> > Finished in 2.1 seconds 1 example, 0 failures
>> > real 1m5.502s
>> > user 0m46.467s
>> > sys 0m14.455s
>>
>> When you run `rake spec` it loads up the Rails development environment
>> (because that's the environment you're running rake in) and then
>> shells out the `rspec spec` command with the Rails test environment.
>> That's why `rake spec` will always take longer than running `rspec
>> spec`.
>>
>> > $time rspec spec
>> > Finished in 1.39 seconds 1 example, 0 failures
>> > real 0m51.350s
>> > user 0m36.069s
>> > sys 0m12.842s
>>
>> When you run with `--tag focus` on the command line, or
>> `config.filter_run_including :focus`, rspec evaluates the metadata for
>> every example in the suite in order to find the one(s) that match(es)
>> the tag. It's possible that you've got a filter in your config or in a
>> spec that takes a long time to evaluate. What's in RSpec.configure in
>> spec/spec_helper.rb?
>>
>> David
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>
>
>
>
> --
> Rainer Kuhn
>
> Rails Developer
> Incutio :: www.incutio.com
> http://www.facebook.com/Incutio
> https://twitter.com/incutio
>
> UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, Wrexham,
> LL13 9UG.
>
> US Head Office: 33 South Commercial Street, Manchester, NH 03101
>
> T: +44 (0) 1978 661 666
> F: +44 (0)7092 181 581
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users


More information about the rspec-users mailing list