Skip to content

Commit

Permalink
quick huff bench
Browse files Browse the repository at this point in the history
  • Loading branch information
onionpancakes committed Feb 24, 2024
1 parent 84f9abc commit 5d5d9d1
Show file tree
Hide file tree
Showing 6 changed files with 24,137 additions and 7 deletions.
9 changes: 5 additions & 4 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

:aliases
{:dev
{:extra-deps {criterium/criterium {:mvn/version "0.4.6"}
hiccup/hiccup {:mvn/version "2.0.0-RC3"}
selmer/selmer {:mvn/version "1.12.59"}
enlive/enlive {:mvn/version "1.1.6"}}
{:extra-deps {criterium/criterium {:mvn/version "0.4.6"}
hiccup/hiccup {:mvn/version "2.0.0-RC3"}
selmer/selmer {:mvn/version "1.12.59"}
enlive/enlive {:mvn/version "1.1.6"}
io.github.escherize/huff {:mvn/version "0.1.8"}}
:extra-paths ["dev" "test" "resources"]}

:build
Expand Down
4 changes: 2 additions & 2 deletions dev/bench/chassis.clj
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@

(defn item-element
[item]
[:div.item {:id (:uuid item)
[:div.item {:id (str (:uuid item))
:class (:type item)}
[:h2 (:name item)]
[:p (:date item)]
[:p (str (:date item))]
[:p [:a.baz.buz {:href (str "/item/" (:uuid item))}
"See more details."]]
[:h3 "Description"]
Expand Down
70 changes: 69 additions & 1 deletion dev/user.clj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,75 @@
[dev.onionpancakes.chassis.tests.test-compiler :as tc]
[criterium.core :refer [bench quick-bench]]
[hiccup2.core :as hiccup]
[clojure.walk :refer [macroexpand-all]]))
[clojure.walk :refer [macroexpand-all]]
[clojure.edn]
[clojure.java.io]
[huff2.core :as huff]))

(defn read-from-file
[init f]
(with-open [rdr (-> (clojure.java.io/file f)
(clojure.java.io/reader)
(java.io.PushbackReader.))]
(->> (repeatedly #(clojure.edn/read {:eof :eof} rdr))
(eduction (take-while (complement #{:eof})))
(into init))))

(def chass-page-mid
(read-from-file [] "resources/medium_page.edn"))
(def chass-page-big
(read-from-file [] "resources/big_page.edn"))
(def huff-page-mid
(read-from-file [:<>] "resources/medium_page.edn"))
(def huff-page-big
(read-from-file [:<>] "resources/big_page.edn"))
(def hic-page-mid
(->> (read-from-file [] "resources/medium_page.edn")
(apply list)))
(def hic-page-big
(->> (read-from-file [] "resources/big_page.edn")
(apply list)))

(declare data-mid)

(defn huff-bench [_]
(println "Dev example")
(println "----------------")
(println "Chassis - dev mid")
(quick-bench (c/html (page data-mid)))
(println)
(println "Hiccup - dev mid")
(quick-bench (str (hiccup/html {:mode :html5} (page data-mid))))
(println)
(println "Huff - dev mid")
(quick-bench (huff/html (page data-mid)))
(println)

(println "Huff mid example")
(println "----------------")
(println "Chassis - huff mid")
(quick-bench (c/html chass-page-mid))
(println)
(println "Hiccup - huff mid")
(quick-bench (str (hiccup/html {:mode :html5} hic-page-mid)))
(println)
(println "Huff - huff mid")
(quick-bench (huff/html huff-page-mid))
(println)

(println "Huff big example")
(println "----------------")
(println "Chassis - huff big")
(quick-bench (c/html chass-page-big))
(println)
(println "Hiccup - huff big")
(quick-bench (str (hiccup/html {:mode :html5} hic-page-big)))
(println)
(println "Huff - huff big")
(quick-bench (huff/html huff-page-big))
(println))

;;

(defmethod c/resolve-alias ::Foo
[_ attrs content]
Expand Down
91 changes: 91 additions & 0 deletions resources/bench/huff_bench_results.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
Dev example
----------------
Chassis - dev mid
Evaluation count : 2604 in 6 samples of 434 calls.
Execution time mean : 258.290858 µs
Execution time std-deviation : 2.378918 µs
Execution time lower quantile : 254.422065 µs ( 2.5%)
Execution time upper quantile : 260.587703 µs (97.5%)
Overhead used : 8.825918 ns

Hiccup - dev mid
Evaluation count : 846 in 6 samples of 141 calls.
Execution time mean : 919.993314 µs
Execution time std-deviation : 257.205529 µs
Execution time lower quantile : 727.145262 µs ( 2.5%)
Execution time upper quantile : 1.224977 ms (97.5%)
Overhead used : 8.825918 ns

Huff - dev mid
Evaluation count : 108 in 6 samples of 18 calls.
Execution time mean : 6.241999 ms
Execution time std-deviation : 349.543790 µs
Execution time lower quantile : 5.880985 ms ( 2.5%)
Execution time upper quantile : 6.603692 ms (97.5%)
Overhead used : 8.825918 ns

Huff mid example
----------------
Chassis - huff mid
Evaluation count : 228 in 6 samples of 38 calls.
Execution time mean : 2.796840 ms
Execution time std-deviation : 196.489792 µs
Execution time lower quantile : 2.663282 ms ( 2.5%)
Execution time upper quantile : 3.135417 ms (97.5%)
Overhead used : 8.825918 ns

Found 1 outliers in 6 samples (16.6667 %)
low-severe 1 (16.6667 %)
Variance from outliers : 15.2010 % Variance is moderately inflated by outliers

Hiccup - huff mid
Evaluation count : 36 in 6 samples of 6 calls.
Execution time mean : 19.136768 ms
Execution time std-deviation : 2.835780 ms
Execution time lower quantile : 16.565717 ms ( 2.5%)
Execution time upper quantile : 22.594281 ms (97.5%)
Overhead used : 8.825918 ns

Huff - huff mid
Evaluation count : 12 in 6 samples of 2 calls.
Execution time mean : 56.601502 ms
Execution time std-deviation : 1.594460 ms
Execution time lower quantile : 54.561698 ms ( 2.5%)
Execution time upper quantile : 58.517214 ms (97.5%)
Overhead used : 8.825918 ns

Found 2 outliers in 6 samples (33.3333 %)
low-severe 1 (16.6667 %)
low-mild 1 (16.6667 %)
Variance from outliers : 13.8889 % Variance is moderately inflated by outliers

Huff big example
----------------
Chassis - huff big
Evaluation count : 30 in 6 samples of 5 calls.
Execution time mean : 23.597529 ms
Execution time std-deviation : 1.809435 ms
Execution time lower quantile : 21.774294 ms ( 2.5%)
Execution time upper quantile : 25.625120 ms (97.5%)
Overhead used : 8.825918 ns

Hiccup - huff big
Evaluation count : 6 in 6 samples of 1 calls.
Execution time mean : 157.592734 ms
Execution time std-deviation : 15.799676 ms
Execution time lower quantile : 142.649261 ms ( 2.5%)
Execution time upper quantile : 182.584782 ms (97.5%)
Overhead used : 8.825918 ns

Found 1 outliers in 6 samples (16.6667 %)
low-severe 1 (16.6667 %)
Variance from outliers : 30.4546 % Variance is moderately inflated by outliers

Huff - huff big
Evaluation count : 6 in 6 samples of 1 calls.
Execution time mean : 513.370441 ms
Execution time std-deviation : 15.483784 ms
Execution time lower quantile : 494.535365 ms ( 2.5%)
Execution time upper quantile : 529.783005 ms (97.5%)
Overhead used : 8.825918 ns

Loading

0 comments on commit 5d5d9d1

Please sign in to comment.