Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profiling a cucumber test (ruby/rails)

Profiler/profiling related issue with Cucumber testing.

One of our cucumber tests run fairly slow. In stead of guessing on where our application is spending time, I'd like to know programatically.

How do I trigger a cucumber test with a profiler???

What did not work:

  $ URL=/projects/by/114951412 #URL to slow rails page
  $ script/performance/profiler 'app.get "$URL"' 50

This does not work because 'app.get' only works in console and not available for profiler script

  $ EXPENSIVE_METHOD="Project.find('6300003243').aggregated_total_amount"
  $ script/performance/profiler "$EXPENSIVE_METHOD" 50

This gives a result but I have to guess that this method is the bottleneck

(I'm using cucumber 0.3.94, rails 2.3.2, ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.6.0])

like image 721
Jesper Rønn-Jensen Avatar asked Dec 14 '22 03:12

Jesper Rønn-Jensen


2 Answers

Also try cucumber --format usage to get some stats about the slowest steps.

like image 56
Aslak Hellesøy Avatar answered Dec 27 '22 09:12

Aslak Hellesøy


One more experiment is actually an answer to my question but did not give me but does not really give me a particularly useful result

$ PROJECT_DIR=`pwd`
$ which cucumber
/usr/local/bin/cucumber
$ ln -s `which cucumber` cukes #required for profiler to have local file in next step
$ ruby-prof cukes -- features/manager_overview.feature:36

This actually runs the single cucumber scenario on line 36, but the result is not particularly useful

like image 42
Jesper Rønn-Jensen Avatar answered Dec 27 '22 09:12

Jesper Rønn-Jensen