Skip to content

Instantly share code, notes, and snippets.

@jebberjeb
Created November 17, 2014 21:39
Show Gist options
  • Save jebberjeb/7a018adecb85a43b3373 to your computer and use it in GitHub Desktop.
Save jebberjeb/7a018adecb85a43b3373 to your computer and use it in GitHub Desktop.
Profiling Magrathea
(ns profiling
(:require [magrathea.server.routes :refer (app)]
[ring.mock.request :as mock]
[taoensso.timbre.profiling :as p]))
(def req (mock/request
:get
"/organization/085cafea-868b-4db2-958c-641988553c5b/my-account"))
(defn do-with-orgs
[orgs-fn label times]
(with-redefs-fn {#'magrathea.server.middleware/wrap-authentication identity
#'magrathea.server.middleware/wrap-authorization identity
#'magrathea.db.users/orgs orgs-fn}
#(dotimes [n times] (p/p label (app req)))))
(def do-without-memo (partial do-with-orgs magrathea.db.users/orgs :no-memo))
(def do-with-memo (partial do-with-orgs (memoize magrathea.db.users/orgs)
:memo))
(defn do-it
[times]
(do-without-memo times)
(do-with-memo times))
#_(p/profile :info :requests (do-it 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment