From 21298dba5d894e91d2840545e3539dc9e50cb53a Mon Sep 17 00:00:00 2001 From: Chris Allen Date: Sun, 28 Jul 2013 13:29:08 -0700 Subject: [PATCH] selmer, per library wrap-ups --- project.clj | 1 + src/clojure_template_benchmarks/core.clj | 65 +++++++++++++++++------- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/project.clj b/project.clj index fada044..d9c2b7a 100644 --- a/project.clj +++ b/project.clj @@ -10,6 +10,7 @@ [enlive "1.1.1"] [hiccup "1.0.3"] [stencil "0.3.2"] + [selmer "0.1.8"] [tinsel "0.4.0" :exclusions [hickory]] [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 e52e017..6d5de4d 100644 --- a/src/clojure_template_benchmarks/core.clj +++ b/src/clojure_template_benchmarks/core.clj @@ -2,6 +2,7 @@ (:use criterium.core tinsel.core) (:require [clabango.parser :refer [render render-file]] + [selmer.parser :as selmer] [stencil.core :as stencil] [hiccup.core :as hiccup] [me.raynes.laser :as laser :refer [defdocument]] @@ -52,6 +53,13 @@ (render-file "clojure_template_benchmarks/templates/list.html" {:items (range 1 ceil)})) +(defn simple-selmer [] + (selmer/render-file "src/clojure_template_benchmarks/templates/simple.html" {:bar bar})) + +(defn list-selmer [ceil] + (selmer/render-file "src/clojure_template_benchmarks/templates/list.html" {:items (range 1 ceil)})) + + (defn simple-stencil-no-fd [] (stencil/render-string "{{bar}}" {:bar bar})) @@ -100,20 +108,16 @@ (defn simple-enlive [] (apply str (simple-enlive-core))) (defn list-enlive [ceil] (apply str (list-enlive-core ceil))) -(defn -main [& args] - ;; (println (simple-hiccup)) - ;; (println (simple-clabango-no-fd)) - ;; (println (count (list-filler-hiccup))) - ;; (println (count (list-filler-clabango-no-fd))) - +(defn str-benches [] (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")) +(defn hiccup-benches [] (println "\n\n ***** hiccup benchmarks ***** \n\n") (with-progress-reporting (quick-bench (simple-hiccup))) (println "\n --- \n") @@ -121,15 +125,15 @@ (println "\n --- \n") (with-progress-reporting (quick-bench (list-hiccup 1000))) (println "\n --- \n") - (println "\n\n ***** type-hinted hiccup benchmarks ***** \n\n") (with-progress-reporting (quick-bench (simple-hiccup-hint))) (println "\n --- \n") (with-progress-reporting (quick-bench (list-hiccup-hint 50))) (println "\n --- \n") (with-progress-reporting (quick-bench (list-hiccup-hint 1000))) - (println "\n --- \n") + (println "\n --- \n")) +(defn clabango-benches [] (println "\n\n ***** clabango string ***** \n\n") (quick-bench (simple-clabango-no-fd)) (println "\n --- \n") @@ -144,8 +148,18 @@ (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")) +(defn selmer-benches [] + (println "\n\n ***** selmer from file template ***** \n\n") + (with-progress-reporting (quick-bench (simple-selmer))) + (println "\n --- \n") + (with-progress-reporting (quick-bench (list-selmer 50))) + (println "\n --- \n") + (with-progress-reporting (quick-bench (list-selmer 1000))) + (println "\n --- \n")) + +(defn stencil-benches [] (println "\n\n ***** stencil string ***** \n\n") (with-progress-reporting (quick-bench (simple-stencil-no-fd))) (println "\n --- \n") @@ -160,24 +174,27 @@ (with-progress-reporting (quick-bench (list-stencil 50))) (println "\n --- \n") (with-progress-reporting (quick-bench (list-stencil 1000))) - (println "\n --- \n") + (println "\n --- \n")) +(defn mustache-benches [] (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")) +(defn tinsel-benches [] (println "\n\n ***** tinsel ***** \n\n") (with-progress-reporting (quick-bench (simple-tinsel))) (println "\n --- \n") (with-progress-reporting (quick-bench (list-tinsel 50))) (println "\n --- \n") (with-progress-reporting (quick-bench (list-tinsel 1000))) - (println "\n --- \n") + (println "\n --- \n")) +(defn laser-benches [] (println "\n\n ***** laser ***** \n\n") (with-progress-reporting (quick-bench (simple-laser))) (println "\n --- \n") @@ -192,13 +209,27 @@ (with-progress-reporting (quick-bench (list-laser-hinted 50))) (println "\n --- \n") (with-progress-reporting (quick-bench (list-laser-hinted 1000))) - (println "\n --- \n") - + (println "\n --- \n")) + +(defn enlive-benches [] (println "\n\n ***** enlive ***** \n\n") (with-progress-reporting (quick-bench (simple-enlive))) (println "\n --- \n") (with-progress-reporting (quick-bench (list-enlive 50))) (println "\n --- \n") (with-progress-reporting (quick-bench (list-enlive 1000))) - (println "\n --- \n") - ) \ No newline at end of file + (println "\n --- \n")) + +(defn -main [& args] + ;; (println (simple-hiccup)) + ;; (println (simple-clabango-no-fd)) + ;; (println (count (list-filler-hiccup))) + ;; (println (count (list-filler-clabango-no-fd))) + (mustache-benches) + (stencil-benches) + (selmer-benches) + (str-benches) + (hiccup-benches) + (clabango-benches) + (laser-benches) + (enlive-benches))