2013-12-13 20:29:37 +00:00
|
|
|
# Template Engine Performance Comparison
|
|
|
|
#### Ruby implementations.
|
|
|
|
|
|
|
|
## Competitors
|
2013-12-13 21:12:26 +00:00
|
|
|
- Builder
|
2013-12-13 20:29:37 +00:00
|
|
|
- ERB
|
|
|
|
- Erubis
|
|
|
|
- Haml
|
|
|
|
- Liquid
|
2013-12-13 21:12:26 +00:00
|
|
|
- Markaby
|
2013-12-13 20:29:37 +00:00
|
|
|
- Mustache
|
|
|
|
- Slim
|
2013-12-13 21:12:26 +00:00
|
|
|
|
2013-12-13 20:29:37 +00:00
|
|
|
... and our special guest ...
|
2013-12-13 21:12:26 +00:00
|
|
|
|
2013-12-13 20:29:37 +00:00
|
|
|
- String interpolation
|
2013-12-13 06:42:27 +00:00
|
|
|
|
|
|
|
## Running
|
2013-12-13 18:43:03 +00:00
|
|
|
```bash
|
|
|
|
# Prepare workspace
|
2013-12-13 06:42:27 +00:00
|
|
|
git clone git@github.com:localhots/template_engine_comparison.git
|
|
|
|
cd template_engine_comparison
|
|
|
|
bundle install
|
2013-12-13 18:43:03 +00:00
|
|
|
|
|
|
|
# Generate data for templates
|
2013-12-13 19:40:54 +00:00
|
|
|
./fakedata.rb 1000 > data/big.yml
|
2013-12-13 18:43:03 +00:00
|
|
|
|
|
|
|
# Run benchmarks
|
2013-12-13 06:42:27 +00:00
|
|
|
./benchmark.rb
|
|
|
|
```
|
|
|
|
|
|
|
|
## Current Results
|
2013-12-13 20:29:37 +00:00
|
|
|
**Intel Core i7 2.6 GHz**
|
2013-12-13 20:04:31 +00:00
|
|
|
|
2013-12-13 06:42:27 +00:00
|
|
|
```
|
|
|
|
############################################################
|
2013-12-13 19:40:54 +00:00
|
|
|
## Compilation (small) (1000 runs) ##
|
2013-12-13 06:42:27 +00:00
|
|
|
############################################################
|
|
|
|
user system total real
|
2013-12-13 21:12:26 +00:00
|
|
|
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)
|
2013-12-13 06:42:27 +00:00
|
|
|
|
|
|
|
############################################################
|
2013-12-13 19:40:54 +00:00
|
|
|
## Render (small) (1000 runs) ##
|
2013-12-13 06:42:27 +00:00
|
|
|
############################################################
|
|
|
|
user system total real
|
2013-12-13 21:12:26 +00:00
|
|
|
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)
|
2013-12-13 19:40:54 +00:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
## Compilation (big) (1000 runs) ##
|
|
|
|
############################################################
|
|
|
|
user system total real
|
2013-12-13 21:12:26 +00:00
|
|
|
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)
|
2013-12-13 19:40:54 +00:00
|
|
|
|
|
|
|
############################################################
|
2013-12-13 20:04:31 +00:00
|
|
|
## Render (big) (100 runs) ##
|
2013-12-13 19:40:54 +00:00
|
|
|
############################################################
|
|
|
|
user system total real
|
2013-12-13 21:12:26 +00:00
|
|
|
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)
|
2013-12-13 06:42:27 +00:00
|
|
|
```
|