[rspec-users] using before(:all) for cheap benchmark?

David Chelimsky dchelimsky at gmail.com
Sat Feb 12 15:59:11 EST 2011


On Feb 9, 2011, at 9:36 PM, Robert Poor wrote:

> I'm a new (and complete) convert to RSpec, especially when coupled with autotest.
> 
> I notice when automate processes my entire spec directory it takes about eight minutes.  I have many more tests to add before I'm done, so eventually I'll want to streamline my tests.
> 
> Is there a quick and dirty way log the amount of time spent on each file to a log?  That would give me a place to start looking for optimizations.  (For extra credit: is there a way to log the time spent on each individual test?)
> 
> I'll look into using before(:all) and after(:all) for doing this, but if you've already created a benchmark hook for rspec, I'm happy to use your code.

Run the rspec command with the --help flag, like this:

  rspec --help

It lists all of the available options, including --profile, which lists the 10 slowest examples. Doesn't give you exactly what you're saying you want, but it probably sets you in the right direction.

HTH,
David


More information about the rspec-users mailing list