Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

rails-perftest

> 编程语言
Open source

Benchmark and profile your Rails apps

799 stars0 likes0 views
WebsiteGitHub

About

Benchmark and profile your Rails apps

Performance Testing Rails Applications

This guide covers the various ways of performance testing a Ruby on Rails application.

After reading this guide, you will know:

  • The various types of benchmarking and profiling metrics.
  • How to generate performance and benchmarking tests.
  • How to install and use a GC-patched Ruby binary to measure memory usage and object allocation.
  • The benchmarking information provided by Rails inside the log files.
  • Various tools facilitating benchmarking and profiling.

Performance testing is an integral part of the development cycle. It is very important that you don't make your end users wait for too long before the page is completely loaded. Ensuring a pleasant browsing experience for end users and cutting the cost of unnecessary hardware is important for any non-trivial web application.


Installation

As of rails 4 performance tests are no longer part of the default stack. If you want to use performance tests simply follow these instructions.

Add this line to your application's Gemfile:

gem 'rails-perftest'

If you want to benchmark/profile under MRI or REE, add this line as well:

gem 'ruby-prof'

Now run bundle install and you're ready to go.

Performance Test Cases

Rails performance tests are a special type of integration tests, designed for benchmarking and profiling the test code. With performance tests, you can determine where your application's memory or speed problems are coming from, and get a more in-depth picture of those problems.

Generating Performance Tests

Rails provides a generator called performance_test for creating new performance tests:

bash
$ rails generate performance_test homepage

This generates homepage_test.rb in the test/performance directory:

ruby
require 'test_helper'
require 'rails/performance_test_help'

class HomepageTest  "stuff")
  project.create_manager("name" => "David")
  project.milestones 
  

Request Logging

Rails log files contain very useful information about the time taken to serve each request. Here's a typical log file entry:

bash
Processing ItemsController#index (for 127.0.0.1 at 2009-01-08 03:06:39) [GET]
Rendering template within layouts/items
Rendering items/index
Completed in 5ms (View: 2, DB: 0) | 200 OK [http://0.0.0.0/items]

For this section, we're only interested in the last line:

bash
Completed in 5ms (View: 2, DB: 0) | 200 OK [http://0.0.0.0/items]

This data is fairly straightforward to understand. Rails uses millisecond(ms) as the metric to measure the time taken. The complete request spent 5 ms inside Rails, out of which 2 ms were spent rendering views and none was spent communication with the database. It's safe to assume that the remaining 3 ms were spent inside the controller.

Useful Links

Rails Plugins and Gems

  • Rails Analyzer
  • Rails Footnotes
  • Query Reviewer
  • MiniProfiler

Generic Tools

  • httperf
  • ab
  • JMeter
  • kcachegrind

Tutorials and Documentation

  • ruby-prof API Documentation
  • Request Profiling Railscast - Outdated, but useful for understanding call graphs.

Commercial Products

Rails has been lucky to have a few companies dedicated to Rails-specific performance tools:

  • New Relic
  • Scout
  • Skylight

Issues· 13 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言