Created
March 29, 2011 20:32
-
-
Save judofyr/893193 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
From 8489ff9d81a806df12518e4606c0df5bb0fa8095 Mon Sep 17 00:00:00 2001 | |
From: Magnus Holm <[email protected]> | |
Date: Tue, 29 Mar 2011 22:32:21 +0200 | |
Subject: [PATCH] Add Tilt compilation to benchmarks | |
--- | |
benchmarks/run.rb | 16 ++++++++++++++++ | |
1 files changed, 16 insertions(+), 0 deletions(-) | |
diff --git a/benchmarks/run.rb b/benchmarks/run.rb | |
index da87f87..4612b6e 100755 | |
--- a/benchmarks/run.rb | |
+++ b/benchmarks/run.rb | |
@@ -10,6 +10,7 @@ require 'ostruct' | |
require 'erubis' | |
require 'erb' | |
require 'haml' | |
+require 'tilt' | |
class SlimBenchmarks | |
def initialize(slow, iterations) | |
@@ -30,6 +31,11 @@ class SlimBenchmarks | |
haml_ugly = Haml::Engine.new(tpl_haml, :format => :html5, :ugly => true) | |
slim = Slim::Template.new { tpl_slim } | |
+ tilt_erb = Tilt::ERBTemplate.new { tpl_erb } | |
+ tilt_erubis = Tilt::ErubisTemplate.new { tpl_erb } | |
+ tilt_haml = Tilt::HamlTemplate.new(:format => :html5, :ugly => true){ tpl_haml } | |
+ tilt_slim = Slim::Template.new { tpl_slim } | |
+ | |
haml.def_method(view, :run_haml) | |
haml_ugly.def_method(view, :run_haml_ugly) | |
view.instance_eval %{ | |
@@ -61,6 +67,11 @@ class SlimBenchmarks | |
bench('(3) slim') { view.run_slim } | |
bench('(3) haml') { view.run_haml } | |
bench('(3) haml ugly') { view.run_haml_ugly } | |
+ | |
+ bench('(4) erb') { tilt_erb.render(view) } | |
+ bench('(4) erubis') { tilt_erubis.render(view) } | |
+ bench('(4) slim') { tilt_slim.render(view) } | |
+ bench('(4) haml') { tilt_haml.render(view) } | |
end | |
def run | |
@@ -85,6 +96,11 @@ class SlimBenchmarks | |
This is the fastest evaluation strategy because it benchmarks | |
pure execution speed of the generated ruby code. | |
+4. Compiled Tilt benchmark. Template is compiled with Tilt, which gives a more | |
+ accurate result of the performance in production mode in frameworks like | |
+ Sinatra, Ramaze and Camping. (Rails still uses its own template | |
+ compilation.) | |
+ | |
" | |
end | |
-- | |
1.7.2.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment