Sha256: eda2ee9abe7b5c279f8defb49963746e43016c3d4cb05fc03d9f713a7a22f3ae
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require 'benchmark/ips' require 'haml' require 'faml' require 'hamlit' require 'slim' require 'escape_utils/html/haml' unless ARGV[0] $stderr.puts "Usage: #{$PROGRAM_NAME} 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
faml-0.8.1 | benchmark/rendering.rb |
faml-0.8.0 | benchmark/rendering.rb |