Sha256: e4977a91de5bbe09c707170174ba69565cd05788e7f3dbda0128afc6ddbc83dc

Contents?: true

Size: 852 Bytes

Versions: 18

Compression:

Stored size: 852 Bytes

Contents

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

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

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

# Templating engine initialization
puts "BENCHMARK"
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
  }

  scope = Object.new

  Benchmark.bm do |x|
    x.report("haml") do
      N.times do
        haml.render(scope, locals) do end
      end
    end
    x.report("opulent") do
      N.times do
        opulent.render(scope, locals) do end
      end
    end
    x.report("slim") do
      N.times do
        slim.render(scope, locals) do end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
opulent-1.4.0 benchmark/benchmark.rb
opulent-1.3.3 benchmark/benchmark.rb
opulent-1.3.2 benchmark/benchmark.rb
opulent-1.3.1 benchmark/benchmark.rb
opulent-1.3.0 benchmark/benchmark.rb
opulent-1.2.1 benchmark/benchmark.rb
opulent-1.2.0 benchmark/benchmark.rb
opulent-1.1.9 benchmark/benchmark.rb
opulent-1.1.7 benchmark/benchmark.rb
opulent-1.1.6 benchmark/benchmark.rb
opulent-1.1.5 benchmark/benchmark.rb
opulent-1.1.0 benchmark/benchmark.rb
opulent-1.0.9 benchmark/benchmark.rb
opulent-1.0.8 benchmark/benchmark.rb
opulent-1.0.7 benchmark/benchmark.rb
opulent-1.0.4 benchmark/benchmark.rb
opulent-1.0.3 benchmark/benchmark.rb
opulent-1.0.2 benchmark/benchmark.rb