Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'builder'
- require 'rbench'
- require File.dirname(__FILE__) + '/haml/lib/haml'
- def read(filename)
- File.read(File.join(File.dirname(__FILE__), filename))
- end
- RBench.run((ARGV[0] || '10000').to_i) do
- column :builder, :title => 'Builder'
- column :haml, :title => 'Haml'
- column :haml_ugly, :title => 'Haml :ugly'
- report "Report" do
- context = Object.new
- context.instance_variable_set('@content', read('lipsum.txt').gsub(/^(.+)$/, '<p>\1</p>'))
- context.instance_eval(<<RUBY)
- def builder
- xml = Builder::XmlMarkup.new(:indent => 2)
- #{read('builder.builder')}
- xml.target!
- end
- RUBY
- haml = read('haml.haml')
- Haml::Engine.new(haml).def_method(context, :haml)
- Haml::Engine.new(haml, :ugly => true).def_method(context, :haml_ugly)
- builder {context.builder}
- haml {context.haml}
- haml_ugly {context.haml_ugly}
- end
- end
Add Comment
Please, Sign In to add comment