Last active
October 14, 2016 17:49
-
-
Save ursm/6d763f6cf1202ffbb05f6a2507120966 to your computer and use it in GitHub Desktop.
This file contains 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
%foo | |
%bar= i |
This file contains 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
module ApplicationHelper | |
def tag_helper(i) | |
content_tag(:foo) { | |
content_tag(:bar, i) | |
} | |
end | |
def haml_naive(i) | |
Haml::Engine.new(<<~HAML).render(Object.new, i: i).html_safe | |
%foo | |
%bar= i | |
HAML | |
end | |
Haml::Engine.new(<<~HAML).def_method self, :haml_precompiled, :i | |
%foo | |
%bar= i | |
HAML | |
end |
This file contains 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
$ bin/rails s -e production | |
=> Booting Puma | |
=> Rails 5.0.0.1 application starting in production on http://0.0.0.0:3000 | |
=> Run `rails server -h` for more startup options | |
Puma starting in single mode... | |
* Version 3.6.0 (ruby 2.3.1-p112), codename: Sleepy Sunday Serenity | |
* Min threads: 5, max threads: 5 | |
* Environment: production | |
* Listening on tcp://0.0.0.0:3000 | |
Use Ctrl-C to stop | |
user system total real | |
partial 0.150000 0.020000 0.170000 ( 0.168522) | |
tag_helper 0.060000 0.000000 0.060000 ( 0.065240) | |
haml_naive 0.530000 0.000000 0.530000 ( 0.528725) | |
haml_precompiled 0.030000 0.000000 0.030000 ( 0.026623) | |
user system total real | |
partial 0.170000 0.010000 0.180000 ( 0.213928) | |
tag_helper 0.060000 0.010000 0.070000 ( 0.060891) | |
haml_naive 0.430000 0.000000 0.430000 ( 0.438646) | |
haml_precompiled 0.010000 0.000000 0.010000 ( 0.013547) | |
user system total real | |
partial 0.150000 0.010000 0.160000 ( 0.157855) | |
tag_helper 0.070000 0.010000 0.080000 ( 0.074357) | |
haml_naive 0.460000 0.000000 0.460000 ( 0.470439) | |
haml_precompiled 0.010000 0.000000 0.010000 ( 0.010962) |
This file contains 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
- Benchmark.bm 16 do |x| | |
- x.report 'partial' do | |
- 1000.times do |i| | |
= render 'partial', i: i | |
- x.report 'tag_helper' do | |
- 1000.times do |i| | |
= tag_helper i | |
- x.report 'haml_naive' do | |
- 1000.times do |i| | |
= haml_naive i | |
- x.report 'haml_precompiled' do | |
- 1000.times do |i| | |
= haml_precompiled i: i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment