Add Builder and Markaby
This commit is contained in:
parent
0425c8bac9
commit
89467c5c67
|
@ -1,6 +1,7 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
builder (3.2.2)
|
||||
erubis (2.7.0)
|
||||
faker (1.2.0)
|
||||
i18n (~> 0.5)
|
||||
|
@ -8,6 +9,8 @@ GEM
|
|||
tilt
|
||||
i18n (0.6.9)
|
||||
liquid (2.6.0)
|
||||
markaby (0.7.2)
|
||||
builder (>= 2.0.0)
|
||||
mustache (0.99.5)
|
||||
slim (2.0.2)
|
||||
temple (~> 0.6.6)
|
||||
|
@ -23,6 +26,7 @@ DEPENDENCIES
|
|||
faker
|
||||
haml
|
||||
liquid
|
||||
markaby
|
||||
mustache
|
||||
slim
|
||||
tilt
|
||||
|
|
68
README.md
68
README.md
|
@ -2,13 +2,17 @@
|
|||
#### Ruby implementations.
|
||||
|
||||
## Competitors
|
||||
- Builder
|
||||
- ERB
|
||||
- Erubis
|
||||
- Haml
|
||||
- Liquid
|
||||
- Markaby
|
||||
- Mustache
|
||||
- Slim
|
||||
|
||||
... and our special guest ...
|
||||
|
||||
- String interpolation
|
||||
|
||||
## Running
|
||||
|
@ -33,47 +37,55 @@ bundle install
|
|||
## Compilation (small) (1000 runs) ##
|
||||
############################################################
|
||||
user system total real
|
||||
string 0.040000 0.020000 0.060000 ( 0.053855)
|
||||
erubis 0.060000 0.010000 0.070000 ( 0.075751)
|
||||
erb 0.240000 0.030000 0.270000 ( 0.262077)
|
||||
haml 0.840000 0.020000 0.860000 ( 0.865688)
|
||||
slim 1.930000 0.040000 1.970000 ( 1.968993)
|
||||
mustache 0.020000 0.010000 0.030000 ( 0.030289)
|
||||
liquid 0.080000 0.020000 0.100000 ( 0.104174)
|
||||
string 0.030000 0.020000 0.050000 ( 0.046353)
|
||||
erubis 0.060000 0.020000 0.080000 ( 0.079977)
|
||||
erb 0.260000 0.020000 0.280000 ( 0.273492)
|
||||
haml 0.850000 0.020000 0.870000 ( 0.874163)
|
||||
slim 1.970000 0.040000 2.010000 ( 2.003406)
|
||||
mustache 0.020000 0.010000 0.030000 ( 0.034893)
|
||||
liquid 0.050000 0.020000 0.070000 ( 0.074104)
|
||||
markaby 0.030000 0.020000 0.050000 ( 0.039915)
|
||||
builder 0.020000 0.010000 0.030000 ( 0.039993)
|
||||
|
||||
############################################################
|
||||
## Render (small) (1000 runs) ##
|
||||
############################################################
|
||||
user system total real
|
||||
string 0.010000 0.000000 0.010000 ( 0.007824)
|
||||
erubis 0.010000 0.000000 0.010000 ( 0.008019)
|
||||
erb 0.010000 0.000000 0.010000 ( 0.010448)
|
||||
haml 0.020000 0.000000 0.020000 ( 0.019507)
|
||||
slim 0.020000 0.000000 0.020000 ( 0.019644)
|
||||
mustache 0.230000 0.000000 0.230000 ( 0.232938)
|
||||
liquid 0.040000 0.000000 0.040000 ( 0.044189)
|
||||
string 0.010000 0.000000 0.010000 ( 0.009001)
|
||||
erubis 0.010000 0.000000 0.010000 ( 0.008587)
|
||||
erb 0.010000 0.000000 0.010000 ( 0.012027)
|
||||
haml 0.020000 0.010000 0.030000 ( 0.022236)
|
||||
slim 0.020000 0.000000 0.020000 ( 0.021628)
|
||||
mustache 0.250000 0.000000 0.250000 ( 0.257850)
|
||||
liquid 0.050000 0.000000 0.050000 ( 0.045442)
|
||||
markaby 0.230000 0.000000 0.230000 ( 0.232095)
|
||||
builder 0.200000 0.000000 0.200000 ( 0.196965)
|
||||
|
||||
############################################################
|
||||
## Compilation (big) (1000 runs) ##
|
||||
############################################################
|
||||
user system total real
|
||||
string 0.030000 0.020000 0.050000 ( 0.044706)
|
||||
erubis 0.140000 0.020000 0.160000 ( 0.161244)
|
||||
erb 0.320000 0.030000 0.350000 ( 0.341144)
|
||||
haml 1.180000 0.020000 1.200000 ( 1.205595)
|
||||
slim 2.410000 0.040000 2.450000 ( 2.449355)
|
||||
mustache 0.020000 0.010000 0.030000 ( 0.028152)
|
||||
liquid 0.110000 0.020000 0.130000 ( 0.133382)
|
||||
string 0.030000 0.020000 0.050000 ( 0.043935)
|
||||
erubis 0.150000 0.020000 0.170000 ( 0.176325)
|
||||
erb 0.310000 0.020000 0.330000 ( 0.325486)
|
||||
haml 1.190000 0.030000 1.220000 ( 1.217889)
|
||||
slim 2.430000 0.030000 2.460000 ( 2.468188)
|
||||
mustache 0.020000 0.020000 0.040000 ( 0.031460)
|
||||
liquid 0.110000 0.020000 0.130000 ( 0.134760)
|
||||
markaby 0.030000 0.010000 0.040000 ( 0.039455)
|
||||
builder 0.020000 0.020000 0.040000 ( 0.040826)
|
||||
|
||||
############################################################
|
||||
## Render (big) (100 runs) ##
|
||||
############################################################
|
||||
user system total real
|
||||
string 0.390000 0.020000 0.410000 ( 0.408272)
|
||||
erubis 0.440000 0.020000 0.460000 ( 0.457214)
|
||||
erb 0.640000 0.020000 0.660000 ( 0.656181)
|
||||
haml 0.940000 0.020000 0.960000 ( 0.965373)
|
||||
slim 1.390000 0.000000 1.390000 ( 1.395409)
|
||||
mustache 3.770000 0.010000 3.780000 ( 3.778392)
|
||||
liquid 10.460000 0.050000 10.510000 ( 10.507224)
|
||||
string 0.370000 0.020000 0.390000 ( 0.392442)
|
||||
erubis 0.450000 0.020000 0.470000 ( 0.463274)
|
||||
erb 0.630000 0.020000 0.650000 ( 0.651563)
|
||||
haml 0.970000 0.010000 0.980000 ( 0.982174)
|
||||
slim 1.410000 0.010000 1.420000 ( 1.422800)
|
||||
mustache 3.760000 0.000000 3.760000 ( 3.757236)
|
||||
liquid 10.440000 0.040000 10.480000 ( 10.480874)
|
||||
markaby 11.560000 0.020000 11.580000 ( 11.576669)
|
||||
builder 18.300000 0.030000 18.330000 ( 18.326396)
|
||||
```
|
||||
|
|
10
benchmark.rb
10
benchmark.rb
|
@ -31,7 +31,7 @@ unless File.exist?(big_data_file)
|
|||
raise 'Big data file not found. Please generate it with "./fakedata.rb 10000 > data/big.yml"'
|
||||
end
|
||||
|
||||
small_data = {title: 'Greetings!', username: '%username%'}
|
||||
small_data = {window_title: 'Greetings!', username: '%username%'}
|
||||
big_data = YAML.load_file(big_data_file)
|
||||
|
||||
def banner title
|
||||
|
@ -97,6 +97,14 @@ ENGINES = {
|
|||
class: Tilt::LiquidTemplate,
|
||||
extension: 'liquid'
|
||||
},
|
||||
markaby: {
|
||||
class: Tilt::MarkabyTemplate,
|
||||
extension: 'mab'
|
||||
},
|
||||
builder: {
|
||||
class: Tilt::BuilderTemplate,
|
||||
extension: 'builder'
|
||||
},
|
||||
}
|
||||
|
||||
banner 'Compilation (small) (%d runs)' % COMPILE_LOOPS
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
xml.html do
|
||||
xml.head do
|
||||
xml.title 'Customers List'
|
||||
end
|
||||
xml.body do
|
||||
customers.each do |customer|
|
||||
xml.dl do
|
||||
xml.dt 'Name:'
|
||||
xml.dd customer['name']
|
||||
xml.dt 'Age:'
|
||||
xml.dd customer['age']
|
||||
xml.dt 'Address:'
|
||||
xml.dd do
|
||||
[
|
||||
customer['zip'],
|
||||
customer['country'],
|
||||
customer['city'],
|
||||
customer['address']
|
||||
].join("\n")
|
||||
end
|
||||
xml.dt 'Employer:'
|
||||
xml.dd customer['employer']
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
xml.html do
|
||||
xml.head do
|
||||
xml.title window_title
|
||||
end
|
||||
xml.body do
|
||||
xml.h1 "Hello, #{username}!"
|
||||
xml.p do
|
||||
<<-END
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
||||
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
|
||||
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
|
||||
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
|
||||
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
|
||||
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
|
||||
mollit anim id est laborum.
|
||||
END
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><%= title %></title>
|
||||
<title><%= window_title %></title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, <%= username %>!</h1>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><%= title %></title>
|
||||
<title><%= window_title %></title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, <%= username %>!</h1>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
!!!
|
||||
%html
|
||||
%head
|
||||
%title= title
|
||||
%title= window_title
|
||||
%body
|
||||
%h1
|
||||
Hello,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ title }}</title>
|
||||
<title>{{ window_title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, {{ username }}!</h1>
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
html do
|
||||
head do
|
||||
title 'Customers List'
|
||||
end
|
||||
body do
|
||||
customers.each do |customer|
|
||||
dl do
|
||||
dt 'Name:'
|
||||
dd customer['name']
|
||||
dt 'Age:'
|
||||
dd customer['age']
|
||||
dt 'Address:'
|
||||
dd do
|
||||
[
|
||||
customer['zip'],
|
||||
customer['country'],
|
||||
customer['city'],
|
||||
customer['address']
|
||||
].join("\n")
|
||||
end
|
||||
dt 'Employer:'
|
||||
dd customer['employer']
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
html do
|
||||
head do
|
||||
title window_title
|
||||
end
|
||||
body do
|
||||
h1 "Hello, #{username}!"
|
||||
p do
|
||||
<<-END
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
||||
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
|
||||
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
|
||||
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
|
||||
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
|
||||
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
|
||||
mollit anim id est laborum.
|
||||
END
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ title }}</title>
|
||||
<title>{{ window_title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, {{ username }}!</h1>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
doctype html
|
||||
html
|
||||
head
|
||||
title = title
|
||||
title = window_title
|
||||
body
|
||||
h1 Hello, #{username}!
|
||||
p
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>#{title}</title>
|
||||
<title>#{window_title}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, #{username}!</h1>
|
||||
|
|
Loading…
Reference in New Issue