diff --git a/README.md b/README.md
index f1bda22..b6323d3 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ Test results are avg / standard deviation.
## Data
-Units are in microseconds (us)
+The unit 'us' is microseconds. Typical bullshit "ran this on my macbook" arrangement. Run it on your own thing if you care.
@@ -19,91 +19,91 @@ Units are in microseconds (us)
str |
- 0.165 us / 0.016 us |
- 14 us / 0.253 us |
- 273 us / 14 us |
+ 0.365 us / 0.002 us |
+ 29 us / 0.220 us |
+ 572 us / 2 us |
hiccup |
- 20 us / 0.367 us |
- 1100 us / 59 us |
- 24,000 us / 2900 us |
+ 0.673 us / 0.006 us |
+ 35 us / 1 us |
+ 682 us / 3 us |
hiccup (type-hinted) |
- 0.335 us / 0.013 us |
+ Identical to or slower than non-type-hinted hiccup.
+
clabango (string) |
- 329 us / 5.7 us |
- 1800 us / 146 us |
- 20,600 us / 799 us |
+ 544 us / 6.7 us |
+ 2452 us / 17 us |
+ 30,000 us / 193 us |
clabango (files) |
- 478 us / 42 us |
- 1,790 us / 52 us |
- 19,900 us / 573 us |
+ 665 us / 8.7 us |
+ 2,617 us / 22 us |
+ 30,450 us / 390 us |
stencil (string) |
- 58 us / 6 us |
- 212 us / 27 us |
- 930 us / 37 us |
+ 90 us / 0.5 us |
+ 290 us / 2.7 us |
+ 1,300 us / 13 us |
stencil (file) |
- 1.2 us / 0.022 us |
- 38 us / 0.943 us |
- 784 us / 16 us |
+ 2.2 us / 0.019 us |
+ 58 us / 0.465 us |
+ 1,148 us / 10 us |
+
+
+
+ mustache.clj (file) |
+ 0.947 us / 0.006 us |
+ 26 us / 0.206 us |
+ 541 us / 4.7 us |
tinsel |
- 23.7 us / 5.5 us |
- 1,100 us / 52 us |
- 22,000 us / 770 us |
+ 0.678 us / 0.006 us |
+ 34 us / 0.175 us |
+ 679 us / 7.1 us |
laser |
- 73.6 us / 1.5 us |
- 243 us / 18 us |
- 3,400 us / 61 us |
+ 404 us / 9.4 us |
+ 3,770 us / 26 us |
+ 68,000 us / 925 us |
laser (type-hinted) |
- 73.2 us / 3.0 us |
- 220 us / 21 us |
- 3,090 us / 101 us |
+ 401 us / 3.1 us |
+ 3,764 us / 18 us |
+ 69,408 us / 1,028 us |
enlive |
- 38 us / 0.435 us |
- 320 us / 10 us |
- 6,400 us / 450 us |
+ 47 us / 0.397 us |
+ 385 us / 8.5 us |
+ 6,800 us / 51 us |
## Conclusions
-+ str is really fast and a huge waste of programmer time.
-+ clabango from filesystem templates or string literals are equivalent
-+ clabango and hiccup are equivalent in performance
-+ stencil from string literals is faster than clabango and hiccup,
-+ stencil from files is even faster by a marginal amount.
-+ Enlive and Laser are faster than Hiccup and Clabango
-+ Hiccup benefits greatly from type-hinting and comes close to str
-
Copyright © 2013 bitemyapp
diff --git a/project.clj b/project.clj
index dd72693..fada044 100644
--- a/project.clj
+++ b/project.clj
@@ -4,12 +4,12 @@
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:main clojure-template-benchmarks.core
- :dependencies [[org.clojure/clojure "1.4.0"]
- [clabango "0.4"]
- [criterium "0.3.1"]
- [enlive "1.0.0"]
- [hiccup "1.0.2"]
- [stencil "0.3.0"]
+ :dependencies [[org.clojure/clojure "1.5.1"]
+ [clabango "0.5"]
+ [criterium "0.4.1"] ; 0.3.1
+ [enlive "1.1.1"]
+ [hiccup "1.0.3"]
+ [stencil "0.3.2"]
[tinsel "0.4.0" :exclusions [hickory]]
- [me.raynes/laser "0.1.21"]
- [enlive "1.0.1"]])
\ No newline at end of file
+ [me.raynes/laser "1.1.1"]
+ [me.shenfeng/mustache "1.1"]])
diff --git a/src/clojure_template_benchmarks/core.clj b/src/clojure_template_benchmarks/core.clj
index 448b782..e52e017 100644
--- a/src/clojure_template_benchmarks/core.clj
+++ b/src/clojure_template_benchmarks/core.clj
@@ -5,7 +5,8 @@
[stencil.core :as stencil]
[hiccup.core :as hiccup]
[me.raynes.laser :as laser :refer [defdocument]]
- [net.cgrand.enlive-html :as enlive]))
+ [net.cgrand.enlive-html :as enlive]
+ [me.shenfeng.mustache :as mustache]))
(def bar (str "bar"))
@@ -64,6 +65,14 @@
(defn list-stencil [ceil]
(stencil/render-file "clojure_template_benchmarks/templates/list.mustache" {:items (range 1 ceil)}))
+(mustache/deftemplate simple-mst (slurp "src/clojure_template_benchmarks/templates/simple.mustache"))
+(mustache/deftemplate list-mst (slurp "src/clojure_template_benchmarks/templates/list.mustache"))
+
+(defn simple-mustache []
+ (simple-mst {:bar bar}))
+
+(defn list-mustache [ceil]
+ (list-mst {:items (range 1 ceil)}))
(deftemplate simple-tinsel [[:span {:class "foo"}]] [] (has-class? "foo") (set-content bar))
(deftemplate list-tinsel [[:ul]] [ceil] (tag= :ul) (set-content (for [x (range 1 ceil)] [:li x])))
@@ -71,14 +80,14 @@
(defdocument simple-laser "" []
(laser/class= "foo") (laser/content bar))
(defdocument list-laser "" [ceil]
- (laser/element= :ul) (laser/html-content
+ (laser/element= :ul) (laser/content
(for [x (range 1 ceil)]
(laser/node :li :content (str x)))))
(defdocument simple-laser-hinted "" []
(laser/class= "foo") (laser/content ^String bar))
(defdocument list-laser-hinted "" [ceil]
- (laser/element= :ul) (laser/html-content
+ (laser/element= :ul) (laser/content
(for [x (range 1 ceil)]
(laser/node :li :content (str ^Number x)))))
@@ -153,6 +162,14 @@
(with-progress-reporting (quick-bench (list-stencil 1000)))
(println "\n --- \n")
+ (println "\n\n ***** mustache file ***** \n\n")
+ (with-progress-reporting (quick-bench (simple-mustache)))
+ (println "\n --- \n")
+ (with-progress-reporting (quick-bench (list-mustache 50)))
+ (println "\n --- \n")
+ (with-progress-reporting (quick-bench (list-mustache 1000)))
+ (println "\n --- \n")
+
(println "\n\n ***** tinsel ***** \n\n")
(with-progress-reporting (quick-bench (simple-tinsel)))
(println "\n --- \n")