diff --git a/benchmark/etc/slim_bench.slim b/benchmark/etc/slim_bench.slim new file mode 100644 index 00000000..9853bc7c --- /dev/null +++ b/benchmark/etc/slim_bench.slim @@ -0,0 +1,17 @@ +doctype html +html + head + title Simple Benchmark + body + h1 = header + - unless item.empty? + ul + - for i in item + - if i[:current] + li + strong = i[:name] + - else + li + a href=i[:url] = i[:name] + - else + p The list is empty. diff --git a/bin/bench b/bin/bench index 2008bf21..1e2c8b46 100755 --- a/bin/bench +++ b/bin/bench @@ -3,6 +3,7 @@ require 'bundler/setup' require 'hamlit' require 'faml' +require 'slim' require 'thor' require 'benchmark/ips' require 'hamlit1' if File.exist?('hamlit1') @@ -39,20 +40,21 @@ class Bench < Thor haml = File.read(file) object = Object.new ruby_file = file.gsub(/\.haml\z/, '.rb') - if File.exist?(ruby_file) - object.instance_eval(File.read(ruby_file)) - end + object.instance_eval(File.read(ruby_file)) if File.exist?(ruby_file) + slim_file = file.gsub(/\.haml\z/, '.slim') Haml::Engine.new(haml, escape_html: true, escape_attrs: true, ugly: true).def_method(object, :haml) object.instance_eval "def faml; #{Faml::Engine.new.call(haml)}; end" object.instance_eval "def hamlit; #{Hamlit::Engine.new.call(haml)}; end" object.instance_eval "def hamlit1; #{Hamlit1::Engine.new.call(haml)}; end" if File.exist?('hamlit1') + object.instance_eval "def slim; #{Slim::Engine.new.call(File.read(slim_file))}; end" if File.exist?(slim_file) Benchmark.ips do |x| x.report("haml v#{Haml::VERSION}") { object.haml } x.report("faml v#{Faml::VERSION}") { object.faml } x.report("hamlit#{options[:with_hamlit1] ? '2' : ''} v#{Hamlit::VERSION}") { object.hamlit } x.report("hamlit1 v#{Hamlit1::VERSION}") { object.hamlit1 } if File.exist?('hamlit1') && options[:with_hamlit1] + x.report("slim v#{Hamlit1::VERSION}") { object.slim } if File.exist?(slim_file) x.compare! end end diff --git a/hamlit.gemspec b/hamlit.gemspec index 72a6790d..edf01620 100644 --- a/hamlit.gemspec +++ b/hamlit.gemspec @@ -32,6 +32,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 10.0' spec.add_development_dependency 'redcarpet' spec.add_development_dependency 'sass' + spec.add_development_dependency 'slim' spec.add_development_dependency 'therubyracer' spec.add_development_dependency 'thor', '~> 0.19' spec.add_development_dependency 'unindent'