diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-01-27 16:29:18 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-01-27 16:29:18 -0800 |
commit | 1fb9e6eff71eb84b6cb620282c15b7b89d8e70c1 (patch) | |
tree | af09445c1f3ed8573f29c4766eb653e8da1dac3f /railties/lib/rails/generators/erb.rb | |
parent | b06f64c3480cd389d14618540d62da4978918af0 (diff) | |
download | rails-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 'railties/lib/rails/generators/erb.rb')
0 files changed, 0 insertions, 0 deletions