Created
April 25, 2012 22:53
ERB vs Erubis
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 'erb' | |
require 'erubis' | |
require 'benchmark' | |
@hey = "Herro prease" | |
@lols = [ | |
'12', '34', '56', '78', '90', | |
'ab', 'cd', 'ef', 'gh', 'ij', | |
'kl', 'mn', 'op', 'qr', 'st', | |
'uv', 'wx', 'yz', | |
'test', 'tester', 'testing', | |
'php', 'is', 'amaingly', 'shit', | |
'ruby', 'is', 'the', 'awesomeness', | |
] | |
Benchmark.bm(100) do |x| | |
x.report("ERB") do | |
50.times do | |
ERB.new(File.read('./test.erb'), 0, '<>') | |
end | |
end | |
x.report("Erubis") do | |
50.times do | |
Erubis::Eruby.new(File.read('./test.erb')) | |
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
user system total real | |
ERB 0.020000 0.000000 0.020000 ( 0.026359) | |
Erubis 0.010000 0.000000 0.010000 ( 0.006568) |
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
<html> | |
<head> | |
<title>Test</title> | |
</head> | |
<body> | |
<header> | |
<h1>Test</h1> | |
</header> | |
<section> | |
<div class="msg"> | |
<%= @hey %> | |
</div> | |
<div class="lols"> | |
<% @lols.each do |lol| %> | |
<div><%= lol %></div> | |
<% end %> | |
</div> | |
</section> | |
<footer> | |
Test | |
</footer> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment