Forum: RSpec specs run faster separately than together

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jeremy Lightsmith (Guest)
on 2009-01-28 22:26
(Received via mailing list)
So this is weird.

on my current project I've been working on speeding up specs, and I just
found that

time rake spec => 4m 0s

whereas

time rake spec:controllers spec:models spec:helpers spec:lib => 2m 32s

(we don't have any view specs)  any idea why this might be true?  I
compared
numbers of tests and got the same number both ways, just running
everything
together seems to make it take almost twice as long...  Is anyone else
seeing this?

If it matters, we have 1183 tests spread more or less evenly across each
of
controllers, models, helpers, and lib.

Jeremy
Scott T. (Guest)
on 2009-01-28 22:48
(Received via mailing list)
On Jan 28, 2009, at 3:21 PM, Jeremy Lightsmith wrote:

> So this is weird.
>
> on my current project I've been working on speeding up specs, and I
> just found that
>
> time rake spec => 4m 0s
>
> whereas
>
> time rake spec:controllers spec:models spec:helpers spec:lib => 2m 32s

Do those rake tasks run rake db:test:prepare, and other dependencies
of rake spec?

How are you getting those numbers?

Scott
Jeremy Lightsmith (Guest)
on 2009-01-28 23:14
(Received via mailing list)
On Wed, Jan 28, 2009 at 12:34 PM, Scott T.
<removed_email_address@domain.invalid>wrote:

>> whereas
>
Each of those rake tasks are the default generated ones :

    Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
      t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
      t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
    end

So, yes db:test:prepare is a prereq for each of those, which means in
both
cases it gets run exactly once.

As for those numbers, I'm using the time command, I actually run "time
rake
spec" and after the spec it gives me something that looks like :

  real    4m16.242s
  user    3m54.037s
  sys     0m9.008s
This topic is locked and can not be replied to.