Created
October 17, 2012 20:29
-
-
Save cheald/3907949 to your computer and use it in GitHub Desktop.
This file contains 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 'rubygems' | |
require 'benchmark' | |
require 'erubis' | |
class Context | |
def initialize | |
@items = { | |
"Headline 1" => %w[Link1 Link2 Link3 Link4 Link5 Link6 Link7], | |
"Headline 2" => %w[Link1 Link2 Link3 Link4 Link5 Link6 Link7], | |
"Headline 3" => %w[Link1 Link2 Link3 Link4 Link5 Link6 Link7], | |
"Headline 4" => %w[Link1 Link2 Link3 Link4 Link5 Link6 Link7] | |
} | |
end | |
end | |
context = Context.new | |
context_binding = context.instance_eval { binding } | |
@erb_code = open('erb_page.html.erb').read | |
TIMES = 10000 | |
e = Erubis::FastEruby.new(@erb_code) | |
Benchmark.bm do |x| | |
x.report("Erubis") { | |
TIMES.times do | |
e.result(context_binding) | |
end | |
} | |
end |
This file contains 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
% ruby erubis.rb | |
user system total real | |
Erubis 1.140000 0.020000 1.160000 ( 1.170378) | |
8,547 req/sec single-threaded. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment