Skip to content

Commit

Permalink
Add profiling for athens.posh operations
Browse files Browse the repository at this point in the history
  • Loading branch information
pithyless committed Mar 9, 2021
1 parent 75b1d57 commit d0f18d3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
5 changes: 3 additions & 2 deletions src/cljs/athens/effects.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
[day8.re-frame.async-flow-fx]
[goog.dom.selection :refer [setCursorPosition]]
[re-frame.core :refer [dispatch reg-fx]]
[stylefy.core :as stylefy]))
[stylefy.core :as stylefy]
[taoensso.tufte :as tufte]))


;;; Effects
Expand Down Expand Up @@ -237,7 +238,7 @@
(reg-fx
:transact!
(fn [tx-data]
(walk-transact tx-data)))
(tufte/profile {} (walk-transact tx-data))))


(reg-fx
Expand Down
42 changes: 24 additions & 18 deletions src/cljs/athens/posh.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
(:require
[athens.dbrx :as dbrx]
[datascript.core :as d]
[posh.reagent :as posh]))
[posh.reagent :as posh]
[taoensso.tufte :as tufte]))


(def version
Expand All @@ -11,32 +12,37 @@


(defn create-conn [schema]
(case version
:posh (let [conn (d/create-conn schema)]
(posh/posh! conn)
conn)
:dbrx (dbrx/create-conn schema)))
(tufte/p ::create-conn
(case version
:posh (let [conn (d/create-conn schema)]
(posh/posh! conn)
conn)
:dbrx (dbrx/create-conn schema))))


(defn pull [conn selector eid]
(case version
:posh (posh/pull conn selector eid)
:dbrx (dbrx/pull conn selector eid)))
(tufte/p ::pull
(case version
:posh (posh/pull conn selector eid)
:dbrx (dbrx/pull conn selector eid))))


(defn pull-many [conn selector eids]
(case version
:posh (posh/pull-many conn selector eids)
:dbrx (dbrx/pull-many conn selector eids)))
(tufte/p ::pull-many
(case version
:posh (posh/pull-many conn selector eids)
:dbrx (dbrx/pull-many conn selector eids))))


(defn q [query conn & args]
(case version
:posh (apply posh/q query conn args)
:dbrx (apply dbrx/q query conn args)))
(tufte/p ::q
(case version
:posh (apply posh/q query conn args)
:dbrx (apply dbrx/q query conn args))))


(defn transact! [conn tx-data]
(case version
:posh (posh/transact! conn tx-data)
:dbrx (dbrx/transact! conn tx-data)))
(tufte/p ::transact!
(case version
:posh (posh/transact! conn tx-data)
:dbrx (dbrx/transact! conn tx-data))))

0 comments on commit d0f18d3

Please sign in to comment.