Created
January 17, 2010 19:08
-
-
Save judofyr/279515 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "boot" | |
require "rubygems" | |
require "liquid" | |
require "benchmark" | |
template = "{% for item in item_pool %}{{ item.name }}{% endfor %}" | |
item_pool = (1..10).map { |i| { 'name' => "Hello #{i}" } } | |
liquid = Liquid::Template.parse(template) | |
solid = Solid::Template.parse(template) | |
l = liquid.render('item_pool' => item_pool) | |
s = solid.render('item_pool' => item_pool) | |
c = solid.cached_render('item_pool' => item_pool) | |
raise unless l == s && l == c | |
N = 1000 | |
Benchmark.bmbm do |x| | |
x.report("Liquid") do | |
N.times do | |
liquid.render('item_pool' => item_pool) | |
end | |
end | |
x.report("Solid") do | |
N.times do | |
solid.render('item_pool' => item_pool) | |
end | |
end | |
x.report("Solid (cached)") do | |
N.times do | |
solid.cached_render('item_pool' => item_pool) | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rehearsal -------------------------------------------------- | |
Liquid 0.480000 0.000000 0.480000 ( 0.485351) | |
Solid 0.100000 0.000000 0.100000 ( 0.106081) | |
Solid (cached) 0.090000 0.000000 0.090000 ( 0.086169) | |
----------------------------------------- total: 0.670000sec | |
user system total real | |
Liquid 0.440000 0.010000 0.450000 ( 0.440790) | |
Solid 0.110000 0.000000 0.110000 ( 0.106895) | |
Solid (cached) 0.060000 0.000000 0.060000 ( 0.063174) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment