From b3b7db59b5dd10050bee4df9df96fecf71e13dc8 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 15 Nov 2015 00:20:16 -0600 Subject: [PATCH] Renew CI benchmark suite --- benchmark/boolean_attribute.haml | 4 ---- benchmark/class_attribute.haml | 14 ++++------- benchmark/common_attribute.haml | 2 -- benchmark/data_attribute.haml | 8 +++---- .../dynamic_attributes/boolean_attribute.haml | 4 ++++ .../dynamic_attributes/class_attribute.haml | 4 ++++ .../dynamic_attributes/common_attribute.haml | 2 ++ .../dynamic_attributes/data_attribute.haml | 2 ++ .../dynamic_attributes/id_attribute.haml | 2 ++ benchmark/etc/{basic.haml => slim_bench.haml} | 0 benchmark/etc/{basic.rb => slim_bench.rb} | 0 benchmark/id_attribute.haml | 12 ++-------- bin/bench | 7 +++--- wercker.yml | 24 +++++++++---------- 14 files changed, 38 insertions(+), 47 deletions(-) create mode 100644 benchmark/dynamic_attributes/boolean_attribute.haml create mode 100644 benchmark/dynamic_attributes/class_attribute.haml create mode 100644 benchmark/dynamic_attributes/common_attribute.haml create mode 100644 benchmark/dynamic_attributes/data_attribute.haml create mode 100644 benchmark/dynamic_attributes/id_attribute.haml rename benchmark/etc/{basic.haml => slim_bench.haml} (100%) rename benchmark/etc/{basic.rb => slim_bench.rb} (100%) diff --git a/benchmark/boolean_attribute.haml b/benchmark/boolean_attribute.haml index 78b398fa..82587a6b 100644 --- a/benchmark/boolean_attribute.haml +++ b/benchmark/boolean_attribute.haml @@ -4,7 +4,3 @@ %input{ disabled: disabled } - disabled = true %input{ disabled: disabled } -- hash = { disabled: false } -%input{ hash } -- hash = { disabled: true } -%input{ hash } diff --git a/benchmark/class_attribute.haml b/benchmark/class_attribute.haml index d0bf794b..2faaf7e6 100644 --- a/benchmark/class_attribute.haml +++ b/benchmark/class_attribute.haml @@ -1,11 +1,5 @@ -%div{ class: 'content active' } -- c = %w[content active] -%div{ class: c } -- hash = { class: %w[content active] } -%div{ hash } - .book{ class: 'content active' } -- c = %w[content active] -.book{ class: c } -- hash = { class: %w[content active] } -.book{ hash } +.book(class='content active') + +- klass = %w[content active] +.book{ class: klass } diff --git a/benchmark/common_attribute.haml b/benchmark/common_attribute.haml index f46b01ad..7516da98 100644 --- a/benchmark/common_attribute.haml +++ b/benchmark/common_attribute.haml @@ -1,5 +1,3 @@ %a{ href: '&"\'<>' } - href = '&"\'<>' %a{ href: href } -- hash = { href: '&"\'<>' } -%a{ hash } diff --git a/benchmark/data_attribute.haml b/benchmark/data_attribute.haml index 747811cc..b2ba20c5 100644 --- a/benchmark/data_attribute.haml +++ b/benchmark/data_attribute.haml @@ -1,6 +1,4 @@ +%div{ data: { disabled: false } } %div{ data: { disabled: true } } -- hash = { data: { disabled: true } } -%div{ hash } -- hash = { 'user' => { id: 1234, name: 'eagletmt' }, book_id: 5432 } -%div{ data: hash } - Book +- hash = { 'user' => { id: 1234, name: 'k0kubun' }, book_id: 5432 } +%div{ data: hash } data diff --git a/benchmark/dynamic_attributes/boolean_attribute.haml b/benchmark/dynamic_attributes/boolean_attribute.haml new file mode 100644 index 00000000..f619d539 --- /dev/null +++ b/benchmark/dynamic_attributes/boolean_attribute.haml @@ -0,0 +1,4 @@ +- hash = { disabled: false } +%input{ hash } +- hash = { disabled: true } +%input{ hash } diff --git a/benchmark/dynamic_attributes/class_attribute.haml b/benchmark/dynamic_attributes/class_attribute.haml new file mode 100644 index 00000000..3c750de8 --- /dev/null +++ b/benchmark/dynamic_attributes/class_attribute.haml @@ -0,0 +1,4 @@ +- hash = { class: %w[content active] } +.book{ hash } +- arr = %w[foo bar] +.book(class=arr){ hash } diff --git a/benchmark/dynamic_attributes/common_attribute.haml b/benchmark/dynamic_attributes/common_attribute.haml new file mode 100644 index 00000000..9c3e19f6 --- /dev/null +++ b/benchmark/dynamic_attributes/common_attribute.haml @@ -0,0 +1,2 @@ +- hash = { href: '&"\'<>' } +%a{ hash } diff --git a/benchmark/dynamic_attributes/data_attribute.haml b/benchmark/dynamic_attributes/data_attribute.haml new file mode 100644 index 00000000..a53d89b3 --- /dev/null +++ b/benchmark/dynamic_attributes/data_attribute.haml @@ -0,0 +1,2 @@ +- hash = { data: { 'user' => { id: 1234, name: 'k0kubun' }, book_id: 5432 } } +%div{ hash } data diff --git a/benchmark/dynamic_attributes/id_attribute.haml b/benchmark/dynamic_attributes/id_attribute.haml new file mode 100644 index 00000000..29698937 --- /dev/null +++ b/benchmark/dynamic_attributes/id_attribute.haml @@ -0,0 +1,2 @@ +- hash = { id: %w[content active] } +#book{ hash } diff --git a/benchmark/etc/basic.haml b/benchmark/etc/slim_bench.haml similarity index 100% rename from benchmark/etc/basic.haml rename to benchmark/etc/slim_bench.haml diff --git a/benchmark/etc/basic.rb b/benchmark/etc/slim_bench.rb similarity index 100% rename from benchmark/etc/basic.rb rename to benchmark/etc/slim_bench.rb diff --git a/benchmark/id_attribute.haml b/benchmark/id_attribute.haml index b40905a6..af6acf65 100644 --- a/benchmark/id_attribute.haml +++ b/benchmark/id_attribute.haml @@ -1,11 +1,3 @@ -%div{ id: 'content active' } -- i = %w[content active] -%div{ id: i } -- hash = { id: %w[content active] } -%div{ hash } - #book{ id: 'content active' } -- c = %w[content active] -#book{ id: c } -- hash = { id: %w[content active] } -#book{ hash } +- id = %w[content active] +#book{ id: id } diff --git a/bin/bench b/bin/bench index 73de5d3f..d808d406 100755 --- a/bin/bench +++ b/bin/bench @@ -10,10 +10,9 @@ require 'hamlit1' if File.exist?('hamlit1') class Bench < Thor desc 'bench HAML', 'Benchmark haml template' option :show_code, type: :boolean, aliases: ['-c'] - def bench(file) - compile(file) - render(file) - code(file) if options[:show_code] + def bench(*files) + files.each { |file| render(file) } + files.each { |file| code(file) if options[:show_code] } end desc 'compile HAML', 'Benchmark compilation' diff --git a/wercker.yml b/wercker.yml index 5a239074..ee0c8e6e 100644 --- a/wercker.yml +++ b/wercker.yml @@ -6,23 +6,23 @@ build: name: clone hamlit1 code: bin/clone - script: - name: attribute_builder.haml - code: bin/bench bench -c benchmark/attribute_builder.haml + 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 - script: - name: basic.haml - code: bin/bench bench -c benchmark/basic.haml + 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 - script: - name: old_attributes.haml - code: bin/bench bench -c benchmark/old_attributes.haml + name: "[benchmark] plain text" + code: bin/bench bench benchmark/plain.haml - script: - name: plain.haml - code: bin/bench bench -c benchmark/plain.haml + name: "[benchmark] script" + code: bin/bench bench benchmark/script.haml - script: - name: real_sample.haml - code: bin/bench bench -c benchmark/real_sample.haml + name: "[benchmark] attribute_builder bench by faml" + code: bin/bench bench benchmark/etc/attribute_builder.haml - script: - name: tags.haml - code: bin/bench bench -c benchmark/tags.haml + name: "[benchmark] basic bench by slim" + code: bin/bench bench benchmark/etc/slim_bench.haml - script: name: minitest code: bundle exec rake test