Sha256: 0a92e5f762c813a7e79365d9e6bd99419ff547e960ea71f51dabe04c2321467e

Contents?: true

Size: 571 Bytes

Versions: 26

Compression:

Stored size: 571 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'liquid'
require 'benchmark/ips'

puts "Ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
puts "Liquid #{Liquid::VERSION}"

template1 = '{% capture foobar %}foo{{ bar }}{% endcapture %}{{ foo }}{{ foobar }}'
template2 = '{% assign foobar = "foo" | append: bar %}{{ foobar }}'

def render(template)
  Liquid::Template.parse(template).render('bar' => '42')
end

puts render(template1)
puts render(template2)

Benchmark.ips do |x|
  x.report('capture') { render(template1) }
  x.report('assign')  { render(template2) }
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
lbenicio-minimal-v1-1.6.4 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.6.3 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.6.2 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.6.1 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.5.3 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.5.2 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.5.0 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.4.0 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.3.3 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.3.2 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.3.1 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.3.0 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.2.1 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.2.0 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.1.9 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.1.8 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.1.7 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.1.6 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.1.5 benchmark/capture-assign.rb
lbenicio-minimal-v1-1.1.4 benchmark/capture-assign.rb