Polish benchmarks and remove escape_utils dependency
This commit is contained in:
parent
6f742e9064
commit
ebb459d246
1
Gemfile
1
Gemfile
|
@ -18,7 +18,6 @@ else
|
|||
gem 'redcarpet'
|
||||
|
||||
if RUBY_PLATFORM !~ /mswin|mingw/ && RUBY_ENGINE != 'truffleruby'
|
||||
gem 'faml'
|
||||
gem 'stackprof'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'bundler/setup'
|
||||
require 'hamlit'
|
||||
require 'faml'
|
||||
require 'haml'
|
||||
require 'benchmark/ips'
|
||||
require_relative '../utils/benchmark_ips_extension'
|
||||
|
||||
|
@ -10,8 +9,6 @@ h = { 'user' => { id: 1234, name: 'k0kubun' }, book_id: 5432 }
|
|||
|
||||
Benchmark.ips do |x|
|
||||
quote = "'"
|
||||
faml_options = { data: h }
|
||||
x.report("Faml::AB.build") { Faml::AttributeBuilder.build(quote, true, nil, faml_options) }
|
||||
x.report("Haml.build_data") { Haml::AttributeBuilder.build_data(true, quote, h) }
|
||||
x.compare!
|
||||
end
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'bundler/setup'
|
||||
require 'hamlit'
|
||||
require 'faml'
|
||||
require 'haml'
|
||||
require 'benchmark/ips'
|
||||
require_relative '../utils/benchmark_ips_extension'
|
||||
|
||||
Benchmark.ips do |x|
|
||||
x.report("Faml::AB.build") { Faml::AttributeBuilder.build("'", true, nil, {:id=>"book"}, id: %w[content active]) }
|
||||
x.report("Haml::AB.build_id") { Haml::AttributeBuilder.build_id(true, "book", %w[content active]) }
|
||||
x.compare!
|
||||
end
|
||||
|
|
|
@ -43,8 +43,6 @@ require 'tilt'
|
|||
require 'erubi'
|
||||
require 'erb'
|
||||
require 'haml'
|
||||
require 'faml'
|
||||
require 'hamlit'
|
||||
|
||||
class SlimBenchmarks
|
||||
def initialize(only_haml)
|
||||
|
@ -61,20 +59,15 @@ class SlimBenchmarks
|
|||
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)
|
||||
context.instance_eval %{
|
||||
def run_erubi; #{Erubi::Engine.new(@erb_code).src}; end
|
||||
def run_slim_ugly; #{Slim::Engine.new.call @slim_code}; end
|
||||
def run_faml; #{Faml::Engine.new.call @haml_code}; end
|
||||
def run_hamlit; #{Haml::Engine.new.call @haml_code}; end
|
||||
def run_slim; #{Slim::Engine.new.call(@slim_code)}; end
|
||||
def run_haml; #{Haml::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("faml v#{Faml::VERSION}") { context.run_faml }
|
||||
bench("hamlit v#{Haml::VERSION}") { context.run_hamlit }
|
||||
bench("erubi v#{Erubi::VERSION}") { context.run_erubi } unless @only_haml
|
||||
bench("slim v#{Slim::VERSION}") { context.run_slim } unless @only_haml
|
||||
bench("haml v#{Haml::VERSION}") { context.run_haml }
|
||||
end
|
||||
|
||||
def run
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
require 'bundler/setup'
|
||||
require 'haml'
|
||||
require 'faml'
|
||||
require 'thor'
|
||||
require 'benchmark/ips'
|
||||
require_relative '../benchmark/utils/benchmark_ips_extension'
|
||||
|
@ -26,7 +25,6 @@ class Bench < Thor
|
|||
|
||||
Benchmark.ips do |x|
|
||||
x.report("haml v#{Haml::VERSION}") { Haml::Engine.new.call(haml) }
|
||||
x.report("faml v#{Faml::VERSION}") { Faml::Engine.new.call(haml) }
|
||||
x.compare!
|
||||
end
|
||||
end
|
||||
|
@ -43,11 +41,9 @@ class Bench < Thor
|
|||
end
|
||||
|
||||
object.instance_eval "def haml; #{Haml::Engine.new.call(haml)}; end"
|
||||
object.instance_eval "def faml; #{Faml::Engine.new.call(haml)}; end"
|
||||
|
||||
Benchmark.ips do |x|
|
||||
x.report("haml v#{Haml::VERSION}") { object.haml }
|
||||
x.report("faml v#{Faml::VERSION}") { object.faml }
|
||||
x.compare!
|
||||
end
|
||||
end
|
||||
|
@ -57,8 +53,6 @@ class Bench < Thor
|
|||
haml = File.read(file)
|
||||
puts "\n#{?= * 49}\n Haml Source: #{file}\n#{?= * 49}"
|
||||
puts Haml::Engine.new.call(haml)
|
||||
puts "\n#{?= * 49}\n Faml Source: #{file}\n#{?= * 49}"
|
||||
puts Faml::Engine.new.call(haml)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in New Issue