Reputation: 12605
I'm just coming across to RSpec from rake:test, and I'm struggling to find any equivalent to rake test:benchmark and/or rake test:profile.
So, what do most rspec folks use for performance testing? I've found --profile, which spits back the ten slowest tests, but I was hoping for something a little more comprehensive.
Cheers...
Upvotes: 20
Views: 7985
Reputation: 4963
There is rspec-benchmark ruby gem which allows to test the performance in the clean and readable way:
expect { ... }.to perform_under(0.01).sec
You can also specify the number of times to run your code to measure performance:
expect { ... }.to perform_under(0.01).and_sample(10)
Upvotes: 5
Reputation: 806
The Diaspora project took an interesting approach to performance testing with rspec -- tests that say "this method should be fast / take less than N ms"
Different than the typical approach but implementable without any half-baked rspec plugins
Upvotes: 19