Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save markomafs/17c2d0db1d4f157d035c582d60a39845 to your computer and use it in GitHub Desktop.
Save markomafs/17c2d0db1d4f157d035c582d60a39845 to your computer and use it in GitHub Desktop.
(ns playground
(:require [<service>.components :as b-comp]
[clojure.test :refer :all]
[com.stuartsierra.component :as component]
[common-core.system :as sys]
[criterium.core :as criterium]))
(defn run-criterium []
(criterium/with-progress-reporting (criterium/quick-bench (b-comp/create-and-start-system!) :verbose)))
(defn instrument-start [timings component]
(let [before (System/currentTimeMillis)
started-comp (#'component/start component)
after (System/currentTimeMillis)]
(swap! timings assoc (class component) (- after before))
started-comp
)
)
(def entry-config {:mode sys/default-mode})
(defn system-map [] ((#'sys/select-impls (b-comp/new-system entry-config) entry-config) nil))
(defn run-with-component-timmings []
(let [system (system-map)
timings (atom {})]
(component/update-system system (keys system) (partial instrument-start timings))
(->> timings
deref
seq
(sort-by second)))
)
(comment
(run-criterium)
(run-with-component-timmings))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment