Skip to content

Commit

Permalink
Merge pull request #1 from thomascothran/perf
Browse files Browse the repository at this point in the history
Set up Performance Testing
  • Loading branch information
raystubbs authored Jun 10, 2024
2 parents 8295293 + c96936e commit c17c02f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
46 changes: 46 additions & 0 deletions bench/bench.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
(ns bench
(:require [criterium.core :as c]
[subzero.core :as sz]
[subzero.plugins.html :as zh]
[subzero.plugins.component-registry :as reg]
[hiccup2.core :as h]
[dev.onionpancakes.chassis.core :as ch]))

(set! *warn-on-reflection* true)

(defonce !db
(doto (sz/create-db)
(reg/install!)
(zh/install!)))

(def normal-page
[:html
[:head
[:title "Benchmarks"]
[:link {:rel "stylesheet"
:href "/css/styles.css"}]
[:script {:src "/js/app.js"}]]
[:body
[:div.sidebar
[:ul (for [li-no (range 15)]
[:li [:a {:href (str "/detail/" li-no)}]])]]
[:div.body
(for [col ["a" "b" "c"]]
[:div {:class col}
(for [item (range 15)]
[:p (str "Lorem ipsum " col item)])])]]])

(comment
(do (require '[clj-async-profiler.core :as prof])
(prof/profile (dotimes [_ 6000]
(zh/html !db normal-page)))
(prof/serve-ui 8888)))

(defn bench-all!
[]
(c/quick-bench (zh/html !db normal-page))
(c/quick-bench (str (h/html normal-page)))
(c/quick-bench (ch/html normal-page)))

(comment
(bench-all!))
13 changes: 12 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,15 @@
{:extra-paths ["test/cljc" "test/clj"]
:extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}}}
:exec-fn cognitect.test-runner.api/test}

:bench
{:extra-deps {criterium/criterium {:mvn/version "0.4.6"}
dev.onionpancakes/chassis {:mvn/version "1.0.365"}
hiccup/hiccup {:mvn/version "2.0.0-RC3"}
com.clojure-goes-fast/clj-async-profiler {:mvn/version "1.2.0"}
selmer/selmer {:mvn/version "1.12.59"}
enlive/enlive {:mvn/version "1.1.6"}}
:jvm-opts ["-Djdk.attach.allowAttachSelf"]
:extra-paths ["dev" "test" "resources" "bench"]
:exec-fn bench/bench-all}}}

0 comments on commit c17c02f

Please sign in to comment.