From df9f44de4fa5c1f520cf76e231206d815eed3b03 Mon Sep 17 00:00:00 2001 From: Chris Allen Date: Tue, 29 Jan 2013 23:25:33 -0800 Subject: [PATCH] initial commit --- .gitignore | 12 +++ README.md | 13 +++ doc/intro.md | 3 + project.clj | 11 +++ src/clojure_template_benchmarks/core.clj | 79 +++++++++++++++++++ .../templates/list.html | 1 + .../templates/simple.html | 1 + .../clojure_template_benchmarks/core_test.clj | 8 ++ 8 files changed, 128 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 doc/intro.md create mode 100644 project.clj create mode 100644 src/clojure_template_benchmarks/core.clj create mode 100644 src/clojure_template_benchmarks/templates/list.html create mode 100644 src/clojure_template_benchmarks/templates/simple.html create mode 100644 test/clojure_template_benchmarks/core_test.clj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cc2ff39 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +/target +/lib +/classes +/checkouts +pom.xml +pom.xml.asc +*.jar +*.class +.lein-deps-sum +.lein-failures +.lein-plugins +.lein-repl-history diff --git a/README.md b/README.md new file mode 100644 index 0000000..0f2d9e4 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# clojure-template-benchmarks + +A Clojure library designed to ... well, that part is up to you. + +## Usage + +FIXME + +## License + +Copyright © 2013 FIXME + +Distributed under the Eclipse Public License, the same as Clojure. diff --git a/doc/intro.md b/doc/intro.md new file mode 100644 index 0000000..021268d --- /dev/null +++ b/doc/intro.md @@ -0,0 +1,3 @@ +# Introduction to clojure-template-benchmarks + +TODO: write [great documentation](http://jacobian.org/writing/great-documentation/what-to-write/) diff --git a/project.clj b/project.clj new file mode 100644 index 0000000..2e2a542 --- /dev/null +++ b/project.clj @@ -0,0 +1,11 @@ +(defproject clojure-template-benchmarks "0.1.0-SNAPSHOT" + :description "FIXME: write description" + :url "http://example.com/FIXME" + :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"] + [criterium "0.3.1"] + [hiccup "1.0.2"] + [clabango "0.4"] + ]) diff --git a/src/clojure_template_benchmarks/core.clj b/src/clojure_template_benchmarks/core.clj new file mode 100644 index 0000000..12edaab --- /dev/null +++ b/src/clojure_template_benchmarks/core.clj @@ -0,0 +1,79 @@ +(ns clojure-template-benchmarks.core + (:use criterium.core + hiccup.core) + (:require [clabango.parser :refer [render render-file]])) + +(def bar (str "bar")) + + +(defn simple-str [] + (str "" + bar + "")) + +(defn list-str [ceil] + (str "")) + + +(defn simple-hiccup [] + (html [:span {:class "foo"} bar])) + +(defn list-hiccup [ceil] + (html [:ul (for [x (range 1 ceil)] + [:li x])])) + + +(defn simple-clabango-no-fd [] + (render (str "{{bar}}") {:bar bar})) + +(defn list-clabango-no-fd [ceil] + (render "" {:items (range 1 ceil)})) + + +(defn simple-clabango [] + (render-file "clojure_template_benchmarks/templates/simple.html" {:bar bar})) + +(defn list-clabango [ceil] + (render-file "clojure_template_benchmarks/templates/list.html" {:items (range 1 ceil)})) + + +(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 ***** 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 literals ***** \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")) diff --git a/src/clojure_template_benchmarks/templates/list.html b/src/clojure_template_benchmarks/templates/list.html new file mode 100644 index 0000000..ce0d20c --- /dev/null +++ b/src/clojure_template_benchmarks/templates/list.html @@ -0,0 +1 @@ + diff --git a/src/clojure_template_benchmarks/templates/simple.html b/src/clojure_template_benchmarks/templates/simple.html new file mode 100644 index 0000000..67c4b3d --- /dev/null +++ b/src/clojure_template_benchmarks/templates/simple.html @@ -0,0 +1 @@ +{{bar}} \ No newline at end of file diff --git a/test/clojure_template_benchmarks/core_test.clj b/test/clojure_template_benchmarks/core_test.clj new file mode 100644 index 0000000..08b8b94 --- /dev/null +++ b/test/clojure_template_benchmarks/core_test.clj @@ -0,0 +1,8 @@ +(ns clojure-template-benchmarks.core-test + (:use clojure.test + clojure-template-benchmarks.core)) + + +(deftest a-test + (testing "FIXME, I fail." + (is (= 0 1))))