From 5518dd1043d4b0eca6474b8dd2cb86e981cbbc6f Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 21 Nov 2015 17:40:30 +0900 Subject: [PATCH] Hamlit1 benchmarking is unnecessary for slim_bench --- bin/bench | 14 +++++++++----- wercker.yml | 10 +++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bin/bench b/bin/bench index d808d406..2008bf21 100755 --- a/bin/bench +++ b/bin/bench @@ -8,10 +8,14 @@ require 'benchmark/ips' require 'hamlit1' if File.exist?('hamlit1') class Bench < Thor + class_option :with_hamlit1, type: :boolean, aliases: ['-w'] + desc 'bench HAML', 'Benchmark haml template' - option :show_code, type: :boolean, aliases: ['-c'] + option :compile, type: :boolean, aliases: ['-c'] + option :show_code, type: :boolean, aliases: ['-s'] def bench(*files) files.each { |file| render(file) } + files.each { |file| compile(file) if options[:compile] } files.each { |file| code(file) if options[:show_code] } end @@ -23,8 +27,8 @@ class Bench < Thor Benchmark.ips do |x| x.report("haml v#{Haml::VERSION}") { Haml::Engine.new(haml, escape_html: true, escape_attrs: true, ugly: true).precompiled } x.report("faml v#{Faml::VERSION}") { Faml::Engine.new.call(haml) } - x.report("hamlit2 v#{Hamlit::VERSION}") { Hamlit::Engine.new.call(haml) } - x.report("hamlit1 v#{Hamlit1::VERSION}") { Hamlit1::Engine.new.call(haml) } if File.exist?('hamlit1') + x.report("hamlit#{options[:with_hamlit1] ? '2' : ''} v#{Hamlit::VERSION}") { Hamlit::Engine.new.call(haml) } + x.report("hamlit1 v#{Hamlit1::VERSION}") { Hamlit1::Engine.new.call(haml) } if File.exist?('hamlit1') && options[:with_hamlit1] x.compare! end end @@ -47,8 +51,8 @@ class Bench < Thor Benchmark.ips do |x| x.report("haml v#{Haml::VERSION}") { object.haml } x.report("faml v#{Faml::VERSION}") { object.faml } - x.report("hamlit2 v#{Hamlit::VERSION}") { object.hamlit } - x.report("hamlit1 v#{Hamlit1::VERSION}") { object.hamlit1 } if File.exist?('hamlit1') + 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.compare! end end diff --git a/wercker.yml b/wercker.yml index 729224d0..31f806d1 100644 --- a/wercker.yml +++ b/wercker.yml @@ -14,19 +14,19 @@ build: code: bin/clone - script: name: "[benchmark] static attributes" - code: bin/bench bench benchmark/boolean_attribute.haml benchmark/class_attribute.haml benchmark/id_attribute.haml benchmark/data_attribute.haml benchmark/common_attribute.haml + code: bin/bench bench -w benchmark/boolean_attribute.haml benchmark/class_attribute.haml benchmark/id_attribute.haml benchmark/data_attribute.haml benchmark/common_attribute.haml - script: name: "[benchmark] dynamic attributes" - code: bin/bench bench benchmark/dynamic_attributes/boolean_attribute.haml benchmark/dynamic_attributes/class_attribute.haml benchmark/dynamic_attributes/id_attribute.haml benchmark/dynamic_attributes/data_attribute.haml benchmark/dynamic_attributes/common_attribute.haml + code: bin/bench bench -w benchmark/dynamic_attributes/boolean_attribute.haml benchmark/dynamic_attributes/class_attribute.haml benchmark/dynamic_attributes/id_attribute.haml benchmark/dynamic_attributes/data_attribute.haml benchmark/dynamic_attributes/common_attribute.haml - script: name: "[benchmark] plain text" - code: bin/bench bench benchmark/plain.haml + code: bin/bench bench -w benchmark/plain.haml - script: name: "[benchmark] script" - code: bin/bench bench benchmark/script.haml + code: bin/bench bench -w benchmark/script.haml - script: name: "[benchmark] attribute_builder bench by faml" - code: bin/bench bench benchmark/etc/attribute_builder.haml + code: bin/bench bench -w benchmark/etc/attribute_builder.haml - script: name: "[benchmark] basic bench by slim" code: bin/bench bench benchmark/etc/slim_bench.haml