Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
(defproject me.shenfeng/mustache "0.0.3" | ||
(defproject me.shenfeng/mustache "0.0.4" | ||
:description "Mustache write in java, for clojure" | ||
:dependencies [[clojure "1.4.0"]] | ||
:warn-on-reflection true | ||
:java-source-path "src/java" | ||
:javac-options {:source "1.6" :target "1.6" :debug "true" :fork "true"} | ||
:dev-dependencies [[swank-clojure "1.4.0"] | ||
[junit/junit "4.8.2"] | ||
[stencil "0.2.0"] | ||
[de.ubercode.clostache/clostache "1.3.0"]]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
(ns me.shenfeng.perf-bench | ||
(:use me.shenfeng.mustache | ||
stencil.core) | ||
(:require [stencil.loader])) | ||
|
||
(def template-str " | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>{{ title }}</title> | ||
</head> | ||
<body> | ||
<ul> | ||
{{#list}}<li>id: {{id}}, name: {{name}}</li> | ||
{{/list}} | ||
</ul> | ||
</body> | ||
</html> | ||
") | ||
|
||
(deftemplate template template-str) | ||
|
||
(def data {:title "mustache clojure implementation" | ||
:list (concat [{:id "https://github.com/davidsantiago/stencil" | ||
:name "stencil"} | ||
{:id "https://github.com/shenfeng/mustache.clj" | ||
:name "shenfeng"}] | ||
(map (fn [id] | ||
{:id id | ||
:name (str "test-test" id)}) (range 1 10)))}) | ||
|
||
(stencil.loader/register-template "hithere" template-str) | ||
|
||
(defn bench [&{:keys [loops] :or {loops 100000}}] | ||
(println "warn up jvm") | ||
(dotimes [i loops] | ||
(to-html template data) | ||
(render-file "hithere" data)) | ||
|
||
(println "bench stencil") | ||
;; from a test run 6671.472264 msecs | ||
(time (dotimes [i loops] | ||
(render-file "hithere" data))) | ||
|
||
;; from a tes run 625.272019 msecs | ||
(println "bench mustache.clj") | ||
(time (dotimes [i loops] | ||
;; bench mustache.clj | ||
(to-html template data)))) |