From 3ef72c09c391b33ec87e08ded3c55b5ca5c07247 Mon Sep 17 00:00:00 2001 From: Anthony Grimes Date: Wed, 30 Jan 2013 04:38:39 -0600 Subject: [PATCH 1/2] 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 From f22d7e0f430e55f362f0584dcd179419ec16eb00 Mon Sep 17 00:00:00 2001 From: Anthony Grimes Date: Wed, 30 Jan 2013 05:03:09 -0600 Subject: [PATCH 2/2] Added Enlive. --- project.clj | 3 ++- src/clojure_template_benchmarks/core.clj | 22 ++++++++++++++----- .../templates/list.enlive | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/project.clj b/project.clj index 949bdf5..dd72693 100644 --- a/project.clj +++ b/project.clj @@ -11,4 +11,5 @@ [hiccup "1.0.2"] [stencil "0.3.0"] [tinsel "0.4.0" :exclusions [hickory]] - [me.raynes/laser "0.1.21"]]) \ No newline at end of file + [me.raynes/laser "0.1.21"] + [enlive "1.0.1"]]) \ No newline at end of file diff --git a/src/clojure_template_benchmarks/core.clj b/src/clojure_template_benchmarks/core.clj index d93098c..09f8be7 100644 --- a/src/clojure_template_benchmarks/core.clj +++ b/src/clojure_template_benchmarks/core.clj @@ -4,7 +4,8 @@ (:require [clabango.parser :refer [render render-file]] [stencil.core :as stencil] [hiccup.core :as hiccup] - [me.raynes.laser :as laser :refer [defdocument]])) + [me.raynes.laser :as laser :refer [defdocument]] + [net.cgrand.enlive-html :as enlive])) (def bar (str "bar")) @@ -67,11 +68,14 @@ (for [x (range 1 ceil)] (laser/node :li :content (str x))))) -(defn simple-enlive [] - (str "")) +(enlive/deftemplate simple-enlive-core "clojure_template_benchmarks/templates/simple.enlive" [] + [:span.foo] (enlive/content bar)) +(enlive/deftemplate list-enlive-core "clojure_template_benchmarks/templates/list.enlive" [ceil] + [:ul] (enlive/clone-for [x (range 1 ceil)] + (enlive/content (str x)))) -(defn list-enlive [ceil] - (str "")) +(defn simple-enlive [] (apply str (simple-enlive-core))) +(defn list-enlive [ceil] (apply str (list-enlive-core ceil))) (defn -main [& args] ;; (println (simple-hiccup)) @@ -142,4 +146,12 @@ (println "\n --- \n") (with-progress-reporting (quick-bench (list-laser 1000))) (println "\n --- \n") + + (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 diff --git a/src/clojure_template_benchmarks/templates/list.enlive b/src/clojure_template_benchmarks/templates/list.enlive index b40db03..389626c 100644 --- a/src/clojure_template_benchmarks/templates/list.enlive +++ b/src/clojure_template_benchmarks/templates/list.enlive @@ -1 +1 @@ - +