initial commit
This commit is contained in:
commit
df9f44de4f
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
|
@ -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
|
13
README.md
Normal file
13
README.md
Normal file
|
@ -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.
|
3
doc/intro.md
Normal file
3
doc/intro.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Introduction to clojure-template-benchmarks
|
||||
|
||||
TODO: write [great documentation](http://jacobian.org/writing/great-documentation/what-to-write/)
|
11
project.clj
Normal file
11
project.clj
Normal file
|
@ -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"]
|
||||
])
|
79
src/clojure_template_benchmarks/core.clj
Normal file
79
src/clojure_template_benchmarks/core.clj
Normal file
|
@ -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 "<span class=\"foo\">"
|
||||
bar
|
||||
"</span>"))
|
||||
|
||||
(defn list-str [ceil]
|
||||
(str "<ul>"
|
||||
(for [n (range 1 ceil)]
|
||||
(str "<li>" n "</li>"))
|
||||
"</ul>"))
|
||||
|
||||
|
||||
(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 "<span class=\"foo\">{{bar}}</span>") {:bar bar}))
|
||||
|
||||
(defn list-clabango-no-fd [ceil]
|
||||
(render "<ul>{% for item in items %}<li>{{item}}</li>{% endfor %}</ul>" {: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"))
|
1
src/clojure_template_benchmarks/templates/list.html
Normal file
1
src/clojure_template_benchmarks/templates/list.html
Normal file
|
@ -0,0 +1 @@
|
|||
<ul>{% for item in items %}<li>{{item}}</li>{% endfor %}</ul>
|
1
src/clojure_template_benchmarks/templates/simple.html
Normal file
1
src/clojure_template_benchmarks/templates/simple.html
Normal file
|
@ -0,0 +1 @@
|
|||
<span class="foo">{{bar}}</span>
|
8
test/clojure_template_benchmarks/core_test.clj
Normal file
8
test/clojure_template_benchmarks/core_test.clj
Normal file
|
@ -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))))
|
Reference in a new issue