$:.unshift 'lib' require "ruby-prof" require 'mustache' require "pathname" template = """ {{#products}}
{{/products}} """ data = { products: [] } 200.times do data[:products] << { :external_index=>"product", :url=>"/products/7", :image=>"products/product.jpg" } end # Uncomment to measure object allocations. Requires ruby 2.0.0 # RubyProf.measure_mode = RubyProf::ALLOCATIONS view = Mustache.new view.template = template view.render # Call render once so the template will be compiled RubyProf.start 500.times do view.render(data) end result = RubyProf.stop printer = RubyProf::GraphHtmlPrinter.new(result) Pathname.new(FileUtils.pwd).join("benchmarks/render_collection_profile.html").open("w+") do |file| printer.print(file, {}) end