Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I benchmark the test suite of a Rails 3 application

I want to optimise a test suite. First I need to know where the time is being spent. As a minimun I want to know how much time is spent in each test.

I came across this gem https://github.com/timocratic/test_benchmark but is no longer maintained.

Notice that my goal is to benchmark the test suite, not the application.

Is there any other gem that I could use?

  • Rails
  • Rspec
  • Capybara
like image 940
Nerian Avatar asked Oct 28 '11 18:10

Nerian


2 Answers

Rspec has a minimum functionality profiler included. Have you looked at it? (blog post tutorial for rspec1 but still valid for rspec2)

Basically, if you specify -p then you get a list of the slowest 10 tests.

like image 163
Kyle Fleming Avatar answered Nov 16 '22 19:11

Kyle Fleming


Are you familiar with the unix time command? If you're just looking to see how long your test suite took to run you can just prepend the time commmand:

time rake spec

After your rspec output you should see something like

Finished in 5.31 seconds
195 examples, 0 failures, 27 pending

real    0m26.580s
user    0m14.085s
sys     0m2.168s

Of course, this is assuming you're on a *nix platform :-)

-a

like image 24
agranov Avatar answered Nov 16 '22 19:11

agranov