Skip to content

Commit

Permalink
Properly cache other template engines for the benchmark.
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Oct 27, 2010
1 parent 0bd56d2 commit eb0bce5
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions benchmarks/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,30 @@ def initialize(iterations)
erb = ERB.new(tpl_erb)
erubis = Erubis::Eruby.new(tpl_erb)
fast_erubis = Erubis::FastEruby.new(tpl_erb)
haml = Haml::Engine.new(tpl_haml)
haml_ugly = Haml::Engine.new(tpl_haml, :ugly => true)
haml = Haml::Engine.new(tpl_haml, :format => :html5)
haml_ugly = Haml::Engine.new(tpl_haml, :format => :html5, :ugly => true)
slim = Slim::Template.new { tpl_slim }

haml.def_method(view, :run_haml)
haml_ugly.def_method(view, :run_haml_ugly)
view.instance_eval(<<RUBY)
def run_erb; #{erb.src}; end
def run_erubis; #{erubis.src}; end
def run_fast_erubis; #{fast_erubis.src}; end
RUBY

bench('erb') { ERB.new(tpl_erb).result(eview) }
bench('erubis') { Erubis::Eruby.new(tpl_erb).result(eview) }
bench('fast erubis') { Erubis::Eruby.new(tpl_erb).result(eview) }
bench('slim') { Slim::Template.new { tpl_slim }.render(view) }
bench('haml') { Haml::Engine.new(tpl_haml).render(view) }
bench('haml ugly') { Haml::Engine.new(tpl_haml, :ugly => true).render(view) }
bench('erb (cached)') { erb.result(eview) }
bench('erubis (cached)') { erubis.result(eview) }
bench('fast erubis (cached)') { fast_erubis.result(eview) }
bench('erb (cached)') { view.run_erb }
bench('erubis (cached)') { view.run_erubis }
bench('fast erubis (cached)') { view.run_fast_erubis }
bench('slim (cached)') { slim.render(view) }
bench('haml (cached)') { haml.render(view) }
bench('haml ugly (cached)') { haml_ugly.render(view) }
bench('haml (cached)') { view.run_haml }
bench('haml ugly (cached)') { view.run_haml_ugly }
end

def run
Expand Down

0 comments on commit eb0bce5

Please sign in to comment.