There are a number of tools and approaches for benchmarking your Rails application. This page will outline some of them.
RailsAnalyzer has benchmarking tools as well as tools for log analysis and status monitoring.
Rails 0.12 (19th April, 2005) Added the BenchmarkerScript and the ProfilerScript to easily benchmark1 and profile Rails code from the command line.
Florian Weber put together some code by that does benchmarking as an extension of test/unit . It also produces a nice html report (see this teaser post for a screen)
This approach allows benchmarking1 to be either very narrow/specific (such as a single method) or very broad/inclusive (such as responding to a request and rendering a view).
Rails 0.13 (6th July, 2005) introduced BenchmarkHelper to measure the execution time of block in a view1. Read the BenchmarkHelper API docs for usage details.
All classes that inherit from ActiveRecord::Base have a benchmark method1 that logs and benchmarks multiple statements in a single block.
Example:
class WeblogController < ActionController::Base
around_filter BenchmarkingFilter.new
# Before this action is performed, BenchmarkingFilter#before(controller) is executed
def index
end
# After this action has been performed, BenchmarkingFilter#after(controller) is executed
end
class BenchmarkingFilter
def initialize
@runtime
end
def before
start_timer
end
def after
stop_timer
report_result
end
end
See the complete filter documentation for more details
1 Rails benchmarking is based on the Benchmark Ruby standard library.
There are a number of tools and approaches for benchmarking your Rails application. This page will outline some of them.
RailsAnalyzer has benchmarking tools as well as tools for log analysis and status monitoring.
Rails 0.12 (19th April, 2005) Added the BenchmarkerScript and the ProfilerScript to easily benchmark1 and profile Rails code from the command line.
Florian Weber put together some code by that does benchmarking as an extension of test/unit . It also produces a nice html report (see this teaser post for a screen)
This approach allows benchmarking1 to be either very narrow/specific (such as a single method) or very broad/inclusive (such as responding to a request and rendering a view).
Rails 0.13 (6th July, 2005) introduced BenchmarkHelper to measure the execution time of block in a view1. Read the BenchmarkHelper API docs for usage details.
All classes that inherit from ActiveRecord::Base have a benchmark method1 that logs and benchmarks multiple statements in a single block.
Example:
class WeblogController < ActionController::Base
around_filter BenchmarkingFilter.new
# Before this action is performed, BenchmarkingFilter#before(controller) is executed
def index
end
# After this action has been performed, BenchmarkingFilter#after(controller) is executed
end
class BenchmarkingFilter
def initialize
@runtime
end
def before
start_timer
end
def after
stop_timer
report_result
end
end
See the complete filter documentation for more details
1 Rails benchmarking is based on the Benchmark Ruby standard library.