aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-01-27 16:29:18 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2015-01-27 16:29:18 -0800
commit1fb9e6eff71eb84b6cb620282c15b7b89d8e70c1 (patch)
treeaf09445c1f3ed8573f29c4766eb653e8da1dac3f /actionpack
parentb06f64c3480cd389d14618540d62da4978918af0 (diff)
downloadrails-1fb9e6eff71eb84b6cb620282c15b7b89d8e70c1.tar.gz
rails-1fb9e6eff71eb84b6cb620282c15b7b89d8e70c1.tar.bz2
rails-1fb9e6eff71eb84b6cb620282c15b7b89d8e70c1.zip
improve performance of integration tests.
I found delegate to be a bottleneck during integration tests. Here is the test case: ```ruby require 'test_helper' class DocumentsIntegrationTest < ActionDispatch::IntegrationTest test "index" do get '/documents' assert_equal 200, response.status end end Minitest.run_one_method(DocumentsIntegrationTest, 'test_index') StackProf.run(mode: :wall, out: 'stackprof.dump') do 3000.times do Minitest.run_one_method(DocumentsIntegrationTest, 'test_index') end end ``` Top of the stack: ``` [aaron@TC integration_performance_test (master)]$ stackprof stackprof.dump ================================== Mode: wall(1000) Samples: 23694 (7.26% miss rate) GC: 1584 (6.69%) ================================== TOTAL (pct) SAMPLES (pct) FRAME 7058 (29.8%) 6178 (26.1%) block in Module#delegate 680 (2.9%) 680 (2.9%) ActiveSupport::PerThreadRegistry#instance 405 (1.7%) 405 (1.7%) ThreadSafe::NonConcurrentCacheBackend#[] 383 (1.6%) 383 (1.6%) Set#include? 317 (1.3%) 317 (1.3%) ActiveRecord::Base.logger 281 (1.2%) 281 (1.2%) Rack::Utils::HeaderHash#[]= 269 (1.1%) 269 (1.1%) ActiveSupport::Notifications::Fanout::Subscribers::Evented#subscribed_to? 262 (1.1%) 262 (1.1%) block (4 levels) in Class#class_attribute 384 (1.6%) 246 (1.0%) block (2 levels) in Class#class_attribute ``` According to @eileencodes's tests, this speeds up integration tests so that they are only 1.4x slower than functional tests: Before: INDEX: Integration Test: 153.2 i/s - 2.43x slower After: INDEX: Integration Test: 275.1 i/s - 1.41x slower
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index b4c861d306..7d8863dfe5 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -419,7 +419,14 @@ module ActionDispatch
# Rails.application.routes.url_helpers.url_for(args)
@_routes = routes
class << self
- delegate :url_for, :optimize_routes_generation?, to: '@_routes'
+ def url_for(options)
+ @_routes.url_for(options)
+ end
+
+ def optimize_routes_generation?
+ @_routes.optimize_routes_generation?
+ end
+
attr_reader :_routes
def url_options; {}; end
end