Skip to content

Commit

Permalink
Fix the slim benchmark for Haml 6
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Oct 9, 2022
1 parent 045e73b commit 89a99f5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions benchmark/slim/run-benchmarks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@ def initialize(only_haml)
def init_compiled_benches
context = Context.new

haml_ugly = Haml::Engine.new(@haml_code, format: :html5, escape_html: true)
haml_ugly.def_method(context, :run_haml_ugly)
if Gem::Version.new(Haml::VERSION) >= Gem::Version.new('6.0.0')
context.instance_eval %{
def run_haml; #{Haml::Engine.new.call @haml_code}; end
}
else
haml = Haml::Engine.new(@haml_code, format: :html5, escape_html: true)
haml.def_method(context, :run_haml)
end
context.instance_eval %{
def run_erubi; #{Erubi::Engine.new(@erb_code).src}; end
def run_slim_ugly; #{Slim::Engine.new.call @slim_code}; end
Expand All @@ -70,7 +76,7 @@ def run_hamlit; #{Hamlit::Engine.new.call @haml_code}; end

bench("erubi v#{Erubi::VERSION}") { context.run_erubi } unless @only_haml
bench("slim v#{Slim::VERSION}") { context.run_slim_ugly } unless @only_haml
bench("haml v#{Haml::VERSION}") { context.run_haml_ugly }
bench("haml v#{Haml::VERSION}") { context.run_haml }
bench("hamlit v#{Hamlit::VERSION}") { context.run_hamlit }
end

Expand Down

0 comments on commit 89a99f5

Please sign in to comment.