Create `rake bench` task

This commit is contained in:
Takashi Kokubun 2015-11-30 20:40:23 +09:00
parent e462d9c003
commit 13e5945d82
4 changed files with 24 additions and 13 deletions

View File

@ -75,5 +75,16 @@ Rake::ExtensionTask.new(:hamlit) do |ext|
ext.lib_dir = 'lib/hamlit'
end
desc 'bench task for CI'
task bench: :compile do
if ENV['SLIM_BENCH'] == '1'
cmd = %w[bundle exec ruby benchmark/slim/run-benchmarks.rb]
else
cmd = ['bin/bench', 'bench', ('-c' if ENV['COMPILE'] == '1'), *ENV['TEMPLATE'].split(',')].compact
end
system('bin/clone')
exit system(*cmd)
end
task default: %w[compile hamlit:test]
task test: %w[compile test:all]

View File

@ -15,7 +15,7 @@ class Bench < Thor
option :compile, type: :boolean, aliases: ['-c']
option :show_code, type: :boolean, aliases: ['-s']
def bench(*files)
files.each { |file| render(file) }
files.each { |file| render(file) unless options[:compile] }
files.each { |file| compile(file) if options[:compile] }
files.each { |file| code(file) if options[:show_code] }
end

View File

@ -1,14 +1,14 @@
#!/bin/bash
if [ -e hamlit1 ]; then
echo 'skipped'
echo 'With hamlit1'
exit 0
fi
git clone --depth=1 -b v1.7.2 https://github.com/k0kubun/hamlit hamlit1
cd hamlit1
git grep --name-only Hamlit | xargs sed -i "" -e "s/Hamlit/Hamlit1/g"
git grep --name-only hamlit | xargs sed -i "" -e "s/hamlit/hamlit1/g"
git grep --name-only Hamlit | xargs sed -i "" -e "s/Hamlit/Hamlit1/g" 2> /dev/null
git grep --name-only hamlit | xargs sed -i "" -e "s/hamlit/hamlit1/g" 2> /dev/null
git mv hamlit.gemspec hamlit1.gemspec
git mv lib/hamlit.rb lib/hamlit1.rb
git mv lib/hamlit lib/hamlit1

View File

@ -9,24 +9,24 @@ build:
- bundle-install
- script:
name: clone hamlit1
code: bin/clone
- script:
name: test all
code: bundle exec rake test
- script:
name: Hamlit::AttributeBuilder.build_data micro benchmark
code: benchmark/ext/build_data.rb
- script:
name: "[benchmark] static attributes"
code: bin/bench bench -t benchmark/boolean_attribute.haml benchmark/class_attribute.haml benchmark/id_attribute.haml benchmark/data_attribute.haml benchmark/common_attribute.haml
code: TEMPLATE=benchmark/boolean_attribute.haml,benchmark/class_attribute.haml,benchmark/id_attribute.haml,benchmark/data_attribute.haml,benchmark/common_attribute.haml bundle exec rake bench
- script:
name: "[benchmark] dynamic attributes"
code: bin/bench bench -t 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: TEMPLATE=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 bundle exec rake bench
- script:
name: "[benchmark] attribute_builder bench by faml"
code: bin/bench bench -t benchmark/etc/attribute_builder.haml
code: TEMPLATE=benchmark/etc/attribute_builder.haml bundle exec rake bench
- script:
name: "[benchmark] benchmark by slim"
code: SLIM_BENCH=1 bundle exec rake bench
- script:
name: "[benchmark] compilation of haml's standard.haml"
code: TEMPLATE=test/haml/templates/standard.haml COMPILE=1 bundle exec rake bench
- rvm-use:
version: 2.1.7