Skip to content

Instantly share code, notes, and snippets.

@whatcould
Created February 27, 2011 19:21
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save whatcould/846442 to your computer and use it in GitHub Desktop.
Save whatcould/846442 to your computer and use it in GitHub Desktop.
Use real data in Rails performance test; see http://m.onkey.org/running-rails-performance-tests-on-real-data
# See http://m.onkey.org/running-rails-performance-tests-on-real-data
# START : HAX HAX HAX
# Load Rails environment in 'test' mode
RAILS_ENV = "test"
require File.expand_path('../../config/environment', __FILE__)
# Re-establish db connection for 'performance' mode
silence_warnings { RAILS_ENV = "performance" }
ActiveRecord::Base.establish_connection
# STOP : HAX HAX HAX
require_dependency 'application_controller'
require 'test/unit'
require 'active_support/core_ext/kernel/requires'
require 'active_support/test_case'
require 'action_controller/test_case'
require 'action_dispatch/testing/integration'
require 'rails/performance_test_help'
# You may want to turn off caching, if you're trying to improve non-cached rendering speed.
# Just uncomment this line:
# ActionController::Base.perform_caching = false
# Seems to be a bug in rails3, gives me a "wrong argument type Class (expected Module) (TypeError)" in Action Dispatch / performance_test.rb
ActiveSupport::Testing::Performance
@jswetnam
Copy link

Beautiful. Thanks very much for this update.

@Sprachprofi
Copy link

This doesn't work - I'm getting an error on line 16, can't load.

@hammady
Copy link

hammady commented Dec 26, 2012

Fixed it to work with Rails 3.2.8, check https://gist.github.com/4378820

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment