forked from lsegal/yard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
erb_vs_erubis.rb
54 lines (45 loc) · 1.13 KB
/
erb_vs_erubis.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# frozen_string_literal: true
require 'rubygems'
require 'erubis'
require 'erubis/tiny'
require 'erb'
require "benchmark"
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard')
def rungen
YARD::Registry.load_yardoc(File.join(File.dirname(__FILE__), '..', '.yardoc'))
YARD::Registry.at("YARD::CodeObjects::Base").format(:format => :html)
end
Benchmark.bmbm do |x|
x.report("erubis") do
eval <<-eof
module YARD; module Templates; module Template
def erb_with(str, x) Erubis::Eruby.new(str) end
end end end
eof
rungen
end
x.report("fast-erubis") do
eval <<-eof
module YARD; module Templates; module Template
def erb_with(str, x) Erubis::FastEruby.new(str) end
end end end
eof
rungen
end
x.report("tiny-erubis") do
eval <<-eof
module YARD; module Templates; module Template
def erb_with(str, x) Erubis::TinyEruby.new(str) end
end end end
eof
rungen
end
x.report("erb") do
eval <<-eof
module YARD; module Templates; module Template
def erb_with(str, x) ERB.new(str) end
end end end
eof
rungen
end
end