How to find which rspec test is taking so long


Rspec Problem Overview

One (or a couple) of our tests are taking forever and we'd like to optimize them.

We have say 1000 tests so it's impractical for me to go through run each file.

Is there an easy to way to find the slow ones?

This is rspec 1.3

Rspec Solutions

Solution 1 - Rspec

In RSpec 2 and 3, you can use the --profile flag or add --profile to your .rspec file. This will track the top 10 slowest examples.

For RSpec 1, you can use --format o with spec command. It shows a text-based progress bar with profiling of 10 slowest examples. For more details see this.

rspec --profile -- path/to/file/spec.rb


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBrian ArmstrongView Question on Stackoverflow
Solution 1 - RspecOcaj NiresView Answer on Stackoverflow