Running performance tests

Performance tests can be run in two modes - benchmarking and profiling modes.

Benchmarking makes it easy to quickly gather a few metrics about each test run. Each test case is run multiple times( by default 4 times) in benchmarking mode.

Performance test can be run in benchmarking mode using

$ rake test:benchmark

Profiling does an in-depth analysis using an external profiler. For MRI this is done using RubyProf. Here each test case is run only once.

Profiling can be done using:

$ rake test:profile

Benchmarking and profiling gives multiple metrics as results including various time, memory and garbage collection metrics. More details can be found in this readme page

Command line tools

For quick and dirty performance testing(without writing performance test files), this also provides command line tools benchmarker and profiler. Each of this command can be run by passing a snippet of code to it.

Performance tests are a useful tools to measure, benchmark and profile blocks of code in your rails applicaton. A well written performance test can help a developer to analyse the most time taking parts of the key execution paths in the application.