Sha256: 0fb6c61225e95807c0bada1ffb643c5ec00e5d58d747edd1f398b4af8cb47ae0
Contents?: true
Size: 1.38 KB
Versions: 7
Compression:
Stored size: 1.38 KB
Contents
#!/usr/bin/env ruby require 'benchmark/ips' require 'haml' require 'faml' require 'hamlit' require 'slim' require 'escape_utils/html/haml' unless ARGV[0] $stderr.puts "Usage: #{$0} template.haml [template.slim]" exit 1 end haml_code = File.read(ARGV[0]) slim_code = ARGV[1] ? File.read(ARGV[1]) : nil Benchmark.ips do |x| obj = Object.new Haml::Engine.new(haml_code, ugly: true, escape_html: true).def_method(obj, :haml) obj.instance_eval %{ def faml_array; #{Faml::Engine.new.call(haml_code)}; end def faml_string; #{Faml::Engine.new(generator: Temple::Generators::RailsOutputBuffer).call(haml_code)}; end def hamlit_array; #{Hamlit::Engine.new.call(haml_code)}; end def hamlit_string; #{Hamlit::Engine.new(generator: Temple::Generators::RailsOutputBuffer).call(haml_code)}; end } if slim_code obj.instance_eval %{ def slim_array; #{Slim::Engine.new.call(slim_code)}; end def slim_string; #{Slim::Engine.new(generator: Temple::Generators::RailsOutputBuffer).call(slim_code)}; end } end x.report('Haml') { obj.haml } x.report('Faml (Array)') { obj.faml_array } x.report('Faml (String)') { obj.faml_string } x.report('Hamlit (Array)') { obj.hamlit_array } x.report('Hamlit (String)') { obj.hamlit_string } if slim_code x.report('Slim (Array)') { obj.slim_array } x.report('Slim (String)') { obj.slim_string } end x.compare! end
Version data entries
7 entries across 7 versions & 1 rubygems