From 3ef72c09c391b33ec87e08ded3c55b5ca5c07247 Mon Sep 17 00:00:00 2001 From: Anthony Grimes Date: Wed, 30 Jan 2013 04:38:39 -0600 Subject: [PATCH] Add laser. --- project.clj | 3 +- src/clojure_template_benchmarks/core.clj | 103 +++++++++++++---------- 2 files changed, 61 insertions(+), 45 deletions(-) diff --git a/project.clj b/project.clj index 4a173e5..949bdf5 100644 --- a/project.clj +++ b/project.clj @@ -10,4 +10,5 @@ [enlive "1.0.0"] [hiccup "1.0.2"] [stencil "0.3.0"] - [tinsel "0.4.0"]]) + [tinsel "0.4.0" :exclusions [hickory]] + [me.raynes/laser "0.1.21"]]) \ No newline at end of file diff --git a/src/clojure_template_benchmarks/core.clj b/src/clojure_template_benchmarks/core.clj index 872dc2c..d93098c 100644 --- a/src/clojure_template_benchmarks/core.clj +++ b/src/clojure_template_benchmarks/core.clj @@ -3,7 +3,8 @@ tinsel.core) (:require [clabango.parser :refer [render render-file]] [stencil.core :as stencil] - [hiccup.core :as hiccup])) + [hiccup.core :as hiccup] + [me.raynes.laser :as laser :refer [defdocument]])) (def bar (str "bar")) @@ -59,6 +60,12 @@ (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]))) +(defdocument simple-laser "" [] + (laser/class= "foo") (laser/content bar)) +(defdocument list-laser "" [ceil] + (laser/element= :ul) (laser/html-content + (for [x (range 1 ceil)] + (laser/node :li :content (str x))))) (defn simple-enlive [] (str "")) @@ -72,53 +79,53 @@ ;; (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") - ;; (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 ***** 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 "\n\n ***** tinsel ***** \n\n") (with-progress-reporting (quick-bench (simple-tinsel))) @@ -127,4 +134,12 @@ (println "\n --- \n") (with-progress-reporting (quick-bench (list-tinsel 1000))) (println "\n --- \n") - ) + + (println "\n\n ***** laser ***** \n\n") + (with-progress-reporting (quick-bench (simple-laser))) + (println "\n --- \n") + (with-progress-reporting (quick-bench (list-laser 50))) + (println "\n --- \n") + (with-progress-reporting (quick-bench (list-laser 1000))) + (println "\n --- \n") + ) \ No newline at end of file