units, goddammit tinsel

This commit is contained in:
Chris Allen 2013-01-30 00:07:29 -08:00
parent 3909b08525
commit 8dfd2006ec
3 changed files with 78 additions and 54 deletions

View file

@ -5,6 +5,9 @@ I decided to do some decent Clojure templating benchmarks:
Test results are avg / standard deviation.
## Data
Units are in microseconds (us)
<table>
<tr>
@ -15,27 +18,27 @@ Test results are avg / standard deviation.
</tr>
<tr>
<td>str</td>
<td>165 ns / 16 ns</td>
<td>14 us / 253 ns</td>
<td>165 us / .016 us</td>
<td>14 us / 0.253 us</td>
<td>273 us / 14 us</td>
</tr>
<tr>
<td>hiccup</td>
<td>20 us / 367 ns</td>
<td>1.1 ms / 59 us</td>
<td>24 ms / 2.9 ms</td>
<td>20 us / 0.367 us</td>
<td>1100 us / 59 us</td>
<td>24,000 us / 2900 us</td>
</tr>
<tr>
<td>clabango (string)</td>
<td>329 us / 5.7 us</td>
<td>1.8 ms / 146 us</td>
<td>20.6 us / 799 us</td>
<td>1800 us / 146 us</td>
<td>20,600 ms / 799 us</td>
</tr>
<tr>
<td>clabango (files)</td>
<td>478 us / 42 us</td>
<td>1.79 ms / 52 us</td>
<td>19.9 ms / 573 us</td>
<td>1,790 us / 52 us</td>
<td>19,900 us / 573 us</td>
</tr>
<tr>
<td>stencil (string)</td>
@ -46,7 +49,7 @@ Test results are avg / standard deviation.
<tr>
<td>stencil (file)</td>
<td>1.2 us / 22 us</td>
<td>38 us / 943 ns</td>
<td>38 us / 0.943 us</td>
<td>784 us / 16 us</td>
</tr>

View file

@ -9,4 +9,4 @@
[hiccup "1.0.2"]
[clabango "0.4"]
[stencil "0.3.0"]
])
[tinsel "0.4.0"]])

View file

@ -1,8 +1,9 @@
(ns clojure-template-benchmarks.core
(:use criterium.core
hiccup.core)
tinsel.core)
(:require [clabango.parser :refer [render render-file]]
[stencil.core :as stencil]))
[stencil.core :as stencil]
[hiccup.core :as hiccup]))
(def bar (str "bar"))
@ -20,10 +21,10 @@
(defn simple-hiccup []
(html [:span {:class "foo"} bar]))
(hiccup/html [:span {:class "foo"} bar]))
(defn list-hiccup [ceil]
(html [:ul (for [x (range 1 ceil)]
(hiccup/html [:ul (for [x (range 1 ceil)]
[:li x])]))
@ -55,56 +56,76 @@
(stencil/render-file "clojure_template_benchmarks/templates/list.mustache" {:items (range 1 ceil)}))
(deftemplate simple-tinsel [[:span {:class "foo"}]]
[]
(set-content bar))
(deftemplate list-tinsel [[:ul]]
[ceil]
(set-content (for [x (range 1 ceil)]
[:li x])))
(defn -main [& args]
;; (println (simple-hiccup))
;; (println (simple-clabango-no-fd))
;; (println (count (list-filler-hiccup)))
;; (println (count (list-filler-clabango-no-fd)))
(println "\n\n ***** str benchmarks ***** \n\n")
(with-progress-reporting (quick-bench (simple-str)))
(println "\n --- \n")
(with-progress-reporting (quick-bench (list-str 50)))
(println "\n --- \n")
(with-progress-reporting (quick-bench (list-str 1000)))
(println "\n --- \n")
;; (println "\n\n ***** str benchmarks ***** \n\n")
;; (with-progress-reporting (quick-bench (simple-str)))
;; (println "\n --- \n")
;; (with-progress-reporting (quick-bench (list-str 50)))
;; (println "\n --- \n")
;; (with-progress-reporting (quick-bench (list-str 1000)))
;; (println "\n --- \n")
(println "\n\n ***** hiccup benchmarks ***** \n\n")
(with-progress-reporting (quick-bench (simple-hiccup)))
(println "\n --- \n")
(with-progress-reporting (quick-bench (list-hiccup 50)))
(println "\n --- \n")
(with-progress-reporting (quick-bench (list-hiccup 1000)))
(println "\n --- \n")
;; (println "\n\n ***** hiccup benchmarks ***** \n\n")
;; (with-progress-reporting (quick-bench (simple-hiccup)))
;; (println "\n --- \n")
;; (with-progress-reporting (quick-bench (list-hiccup 50)))
;; (println "\n --- \n")
;; (with-progress-reporting (quick-bench (list-hiccup 1000)))
;; (println "\n --- \n")
(println "\n\n ***** clabango string ***** \n\n")
(quick-bench (simple-clabango-no-fd))
(println "\n --- \n")
(quick-bench (list-clabango-no-fd 50))
(println "\n --- \n")
(quick-bench (list-clabango-no-fd 1000))
(println "\n --- \n")
;; (println "\n\n ***** clabango string ***** \n\n")
;; (quick-bench (simple-clabango-no-fd))
;; (println "\n --- \n")
;; (quick-bench (list-clabango-no-fd 50))
;; (println "\n --- \n")
;; (quick-bench (list-clabango-no-fd 1000))
;; (println "\n --- \n")
(println "\n\n ***** clabango from file template ***** \n\n")
(with-progress-reporting (quick-bench (simple-clabango)))
(println "\n --- \n")
(with-progress-reporting (quick-bench (list-clabango 50)))
(println "\n --- \n")
(with-progress-reporting (quick-bench (list-clabango 1000)))
(println "\n --- \n")
;; (println "\n\n ***** clabango from file template ***** \n\n")
;; (with-progress-reporting (quick-bench (simple-clabango)))
;; (println "\n --- \n")
;; (with-progress-reporting (quick-bench (list-clabango 50)))
;; (println "\n --- \n")
;; (with-progress-reporting (quick-bench (list-clabango 1000)))
;; (println "\n --- \n")
(println "\n\n ***** stencil string ***** \n\n")
(with-progress-reporting (quick-bench (simple-stencil-no-fd)))
(println "\n --- \n")
(with-progress-reporting (quick-bench (list-stencil-no-fd 50)))
(println "\n --- \n")
(with-progress-reporting (quick-bench (list-stencil-no-fd 1000)))
(println "\n --- \n")
;; (println "\n\n ***** stencil string ***** \n\n")
;; (with-progress-reporting (quick-bench (simple-stencil-no-fd)))
;; (println "\n --- \n")
;; (with-progress-reporting (quick-bench (list-stencil-no-fd 50)))
;; (println "\n --- \n")
;; (with-progress-reporting (quick-bench (list-stencil-no-fd 1000)))
;; (println "\n --- \n")
(println "\n\n ***** stencil file ***** \n\n")
(with-progress-reporting (quick-bench (simple-stencil)))
;; (println "\n\n ***** stencil file ***** \n\n")
;; (with-progress-reporting (quick-bench (simple-stencil)))
;; (println "\n --- \n")
;; (with-progress-reporting (quick-bench (list-stencil 50)))
;; (println "\n --- \n")
;; (with-progress-reporting (quick-bench (list-stencil 1000)))
;; (println "\n --- \n")
(println (simple-tinsel))
(println (list-tinsel 50))
(println "\n\n ***** tinsel ***** \n\n")
(with-progress-reporting (quick-bench (simple-tinsel)))
(println "\n --- \n")
(with-progress-reporting (quick-bench (list-stencil 50)))
(with-progress-reporting (quick-bench (list-tinsel 50)))
(println "\n --- \n")
(with-progress-reporting (quick-bench (list-stencil 1000)))
(with-progress-reporting (quick-bench (list-tinsel 1000)))
(println "\n --- \n"))