Created
March 27, 2017 07:42
-
-
Save ccocchi/856403d8c47a9d4c6beacf7834db3bc8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/concern' | |
require 'active_support/core_ext/object/blank' | |
require 'action_view/buffers' | |
require 'action_view/helpers/output_safety_helper' | |
require 'action_view/helpers/capture_helper' | |
require 'action_view/helpers/tag_helper' | |
require 'benchmark/ips' | |
class Bench | |
include ActionView::Helpers::TagHelper | |
attr_accessor :output_buffer | |
def with_block | |
content_tag(:div, class: 'foo bar foo-bar') do | |
'<i class="fa fa-euro"></i>' | |
end | |
end | |
def inline | |
content_tag(:div, '<i class="fa fa-euro"></i>', class: 'foo bar foo-bar') | |
end | |
end | |
Benchmark.ips do |x| | |
x.report('block') { Bench.new.with_block } | |
x.report('inline') { Bench.new.inline } | |
x.compare! | |
end |
Author
ccocchi
commented
Mar 27, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment