Sha256: 001f111bec63e70c33c6d697a0f070708bcb3da7ae140b9bd08aa483ac30da61

Contents?: true

Size: 579 Bytes

Versions: 6

Compression:

Stored size: 579 Bytes

Contents

#!/usr/bin/env ruby
require 'benchmark/ips'
require 'haml'
require 'fast_haml'
require 'escape_utils/html/haml'

template = ARGV[0]
unless template
  $stderr.puts "Usage: #{$0} template.haml"
  exit 1
end

Benchmark.ips do |x|
  obj = Object.new

  Haml::Engine.new(File.read(template), ugly: true, escape_html: true).def_method(obj, :haml)
  code = FastHaml::Engine.new.call(File.read(template))
  obj.instance_eval("def fast_haml; #{code}; end")

  x.report('Haml rendering') do
    obj.haml
  end

  x.report('FastHaml rendering') do
    obj.fast_haml
  end

  x.compare!
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fast_haml-0.1.5 benchmark/rendering.rb
fast_haml-0.1.4 benchmark/rendering.rb
fast_haml-0.1.3 benchmark/rendering.rb
fast_haml-0.1.2 benchmark/rendering.rb
fast_haml-0.1.1 benchmark/rendering.rb
fast_haml-0.1.0 benchmark/rendering.rb