Sha256: ce8122a49880d6ab3992a32289fc990541f4f85ef34725970ed57a006be7ceff

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

require 'benchmark'
require_relative '../lib/opulent'

# Choose the benchmark you want to run
BENCHMARK = :node

# How many times each command should be run
N = 1000

# Templating engine initialization
puts "BENCHMARK\n--\n"

case BENCHMARK
when :node
  case_folder = 'cases/node/'
  opulent = Tilt.new("#{case_folder}node.op")
  slim = Tilt.new("#{case_folder}node.slim")
  haml = Tilt.new("#{case_folder}node.haml")

  locals = {
    a: 3,
    b: 4,
    c: 5
  }

  op = Opulent.new :"#{case_folder}node"
  # op2 = Opulent.new :"#{case_folder}yield", def: op.def

  puts op.render(op, locals){}
  #
  # puts op.render(op, locals){
  #   op2.render(op, locals){}
  # }

  puts "\n\n"

  puts op.template
  puts "\n\n"

  Benchmark.bm do |x|
    x.report("haml") do
      N.times do
        haml.render(Object.new, locals){}
      end
    end
    x.report("opulent") do
      N.times do
        opulent.render(Object.new, locals){}
      end
    end
    x.report("slim") do
      N.times do
        slim.render(Object.new, locals){}
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
opulent-1.5.5 benchmark/benchmark.rb
opulent-1.5.4 benchmark/benchmark.rb
opulent-1.5.3 benchmark/benchmark.rb
opulent-1.5.2 benchmark/benchmark.rb
opulent-1.5.1 benchmark/benchmark.rb
opulent-1.5.0 benchmark/benchmark.rb
opulent-1.4.8 benchmark/benchmark.rb
opulent-1.4.7 benchmark/benchmark.rb
opulent-1.4.6 benchmark/benchmark.rb
opulent-1.4.5 benchmark/benchmark.rb
opulent-1.4.3 benchmark/benchmark.rb
opulent-1.4.2 benchmark/benchmark.rb
opulent-1.4.1 benchmark/benchmark.rb