Hi, I would like to figure out if it is possible for me to run my specs
faster than it currently is.
Before start optimizing my specs for speed, I tried to figure out what
was the speed footprint of Rspec boot process itself for starting
executing my specs. So I took my simplest spec with a single fast
example:
time bundle exec rspec ./spec/models/decision_spec.rb
.
Finished in 0.00794 seconds
1 example, 0 failures
real 0m19.202s
user 0m17.649s
sys 0m1.300s
All my specs run in about 54s. That means Rspec itself is responsible
for about a third of the total time… Well, not exactly:
time rails runner “puts 1”
1
real 0m13.918s
user 0m12.805s
sys 0m0.940s
This means I could not get more than 5s in the best case from trying to
optimize Rspec itself… Simple does not worth…
Rails (3.0.7rc2) itself takes about 4s to boot up an empty application:
rails new empty
cd empty
time rails runner “puts 1”
1
real 0m4.000s
user 0m3.440s
sys 0m0.492s
That means I can try to optimize my application boot time first, which
can reduce my specs running time up to 10 seconds…
Then, I tried to give autotest a try in the hope it would skip the boot
process for the next spec executions. But it didn’t. It is not that
smart. It just monitor file changes and call rspec on the possible
affected specs…
So, I would like to know if some of you know a good Ruby profiler that
could show me how much time each method takes on a tree view… For
instance, I enjoy very much the Javascript profiler that comes with
Google Chrome Developer Tool.
I tried adding “-r profile” to .rspec, but the output is not that useful
in my opinion… And the “–profile” Rspec option will only show me the
to 10 slowest examples, but not what is the bottleneck, so I need to do
that manually… Also, it won’t help me getting my Rails application to
boot faster…
Does anyone here knows of a good tool for profiling or finding
bottlenecks on a Rails or Ruby application?
Sorry if I took too long on my question…
Cheers, Rodrigo.