1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/benchmark/profile.rake
2015-10-24 20:32:21 +09:00

29 lines
865 B
Ruby

$:.unshift File.expand_path('../lib', __FILE__)
require 'hamlit'
require 'yaml'
desc 'Profile compilation'
task :profile do
yaml_path = File.expand_path('../test/haml-spec/tests.yml', __dir__)
contexts = YAML.load(File.read(yaml_path))
hamlit_engine = Hamlit::Engine.new
Lineprof.profile(/hamlit|temple/) do
contexts.each do |context|
context[1].each do |name, test|
haml = test['haml']
locals = Hash[(test['locals'] || {}).map {|x, y| [x.to_sym, y]}]
options = Hash[(test['config'] || {}).map {|x, y| [x.to_sym, y]}]
options[:format] = options[:format].to_sym if options.key?(:format)
options = { ugly: true }.merge(options)
begin
hamlit_engine.call(haml)
rescue Temple::FilterError, TypeError
end
end
end
end
end