Specs run faster separately than together


#1

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


#2

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


#3

On Wed, Jan 28, 2009 at 12:34 PM, Scott T.
removed_email_address@domain.invalidwrote:

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