File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,5 @@ platform :ruby do
99 gem 'github-markup'
1010 gem 'rails' , '~> 4.2.0' , require : false
1111 gem 'rspec-rails' , require : false
12+ gem 'benchmark-ips' , require : false
1213end
Original file line number Diff line number Diff line change 1+ require 'bundler/setup'
2+ require 'benchmark/ips'
3+
4+ ENV [ "RAILS_ENV" ] = "test"
5+
6+ require_relative '../spec/dummy/config/environment'
7+
8+ class TestPresenter < Curly ::Presenter
9+ def hello_with_delegation
10+ some_helper
11+ end
12+
13+ def hello_without_delegation
14+ not_some_helper
15+ end
16+
17+ private
18+
19+ def not_some_helper
20+ end
21+ end
22+
23+ class TestContext
24+ def some_helper
25+ end
26+ end
27+
28+ context = TestContext . new
29+ presenter = TestPresenter . new ( context )
30+
31+ Benchmark . ips do |x |
32+ x . report "presenter method that delegates to the view context" do
33+ presenter . hello_with_delegation
34+ end
35+
36+ x . report "presenter method that doesn't delegate to the view context" do
37+ presenter . hello_without_delegation
38+ end
39+
40+ x . compare!
41+ end
You can’t perform that action at this time.
0 commit comments