I narrowed it down to three things, the first one might be interesting to
you, the other ones are my problem, although probably common among lots of
projects:

Since we don't mock we usually need a bit of test data prepared for each
test. At first we used factories, but setting things up every time took way
to long. So I went for fixture builder instead. (
http://pivotallabs.com/users/georg/blog/articles/1864-fixture-builder-and-rspec-acceptance)
It was an immediate improvement, although not a great one, since we have a
generic setup_test_data method that runs before most tests and loads from
the database into instance variables.

1) config.global_fixtures = :all
With this line in, the execution of a single focused spec jumps up to a
minute. My unresearched guess is that it might load the fixtures for each
spec, although it won't even be executed.

2) They way I handle fixtures
I am about to change fixture loading to lazy evaluation instead

require 'rspec/core/shared_context'
module LazyFixtures
  extend RSpec::Core::SharedContext
  let(:admin) { User.first }
end

3) My Rails Env doesn't exactly load fast
time rails runner "3 + 4"
real 0m11.521s
user 0m8.531s
sys 0m1.404s

(4) Not really relevant, but a Macbook Air runs out of it's 4GB memory so
fast and starts swapping, next time, I want an iMac!


On Wed, Jun 6, 2012 at 12:50 PM, David Chelimsky <dchelim...@gmail.com>wrote:

> On Wed, Jun 6, 2012 at 6:38 AM, Rainer Kuhn <rai...@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 <dchelim...@gmail.com>
> > wrote:
> >>
> >> On Wed, Jun 6, 2012 at 5:14 AM, Rainer Kuhn <rai...@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@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@rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> _______________________________________________
> rspec-users mailing list
> rspec-users@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@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to