Last active
May 9, 2019 18:12
-
-
Save markomafs/17c2d0db1d4f157d035c582d60a39845 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(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