Provide more granular timing info

This commit is contained in:
Daniel Compton 2018-02-13 10:31:32 +13:00
parent 91ab23d8bf
commit 125cc15fd2
5 changed files with 48 additions and 27 deletions

View File

@ -3,13 +3,17 @@ All notable changes to this project will be documented in this file. This change
## [0.1.20] - Unreleased
### Upgrade notes
To take advantage of the more granular timing info, you will need to upgrade to re-frame 0.10.5.
### Improved
* Improve Timing panel to show more granular timing info.
### Fixed
### Fixed
* View and subscription runtime now only measures self time instead of elapsed time, i.e. we subtract the time of any child subcriptions/renders.
* View and subscription runtime now only measures self time instead of elapsed time, i.e. we subtract the time of any child subcriptions/renders.
## [0.1.19] - 2018-02-09
@ -19,14 +23,14 @@ All notable changes to this project will be documented in this file. This change
* Subscriptions that exist but weren't run, now show up in the subscription panel.
* Subscription creations and disposals that happen during figwheel reloads or otherwise outside of the re-frame event domino cycle are now correctly handled. If any of these happen, they show up in the new section Inter-Epoch Subscriptions.
* All of the actions that happen to a subscription within an epoch are now shown. This lets you spot unusual behaviour like a subscription being created but not-run, or a subscription running multiple times.
* Present better explanation messages when viewing the diff section for a sub where the value is unchanged, not run yet, or only run once.
* Present better explanation messages when viewing the diff section for a sub where the value is unchanged, not run yet, or only run once.
### Fixed
* Garden source dependencies are now working if you don't have your own dependency on Garden.
* New app-db path inspectors default to `"""` instead of `"[]"` so you can see the help text.
## [0.1.18] - 2018-01-31
## [0.1.18] - 2018-01-31
### Fixed

View File

@ -25,8 +25,8 @@
(get-in context [:effects :db])
(get-in context [:coeffects :db]))
event (get-in context [:coeffects :event])]
(f db event) ;; call f for side effects
context)))) ;; context is unchanged
(f db event) ;; call f for side effects
context)))) ;; context is unchanged
(defn log-trace? [trace]
(let [render-operation? (or (= (:op-type trace) :render)
@ -544,16 +544,21 @@
new-sub-state (last subscription-match-state)
timing (mapv (fn [match]
;; TODO: this isn't quite correct, shouldn't be using filtered-traces here
(let [epoch-traces (into []
(comp
(utils/id-between-xf (:id (first match)) (:id (last match))))
filtered-traces)
start-of-epoch (nth epoch-traces 0)
event-handler-trace (utils/spy (first (filter metam/event-handler? epoch-traces)))
finish-run (or (first (filter metam/finish-run? epoch-traces))
(utils/last-in-vec epoch-traces))]
{:re-frame/event-time (metam/elapsed-time start-of-epoch finish-run)
:re-frame/event-handler-time (:duration event-handler-trace)}))
(let [epoch-traces (into []
(comp
(utils/id-between-xf (:id (first match)) (:id (last match))))
filtered-traces)
start-of-epoch (nth epoch-traces 0)
;; TODO: optimise trace searching
event-handler-trace (first (filter metam/event-handler? epoch-traces))
dofx-trace (first (filter metam/event-dofx? epoch-traces))
event-trace (first (filter metam/event-run? epoch-traces))
finish-run (or (first (filter metam/finish-run? epoch-traces))
(utils/last-in-vec epoch-traces))]
{:re-frame/event-run-time (metam/elapsed-time start-of-epoch finish-run)
:re-frame/event-time (:duration event-trace)
:re-frame/event-handler-time (:duration event-handler-trace)
:re-frame/event-dofx-time (:duration dofx-trace)}))
new-matches)
new-matches (map (fn [match sub-match t] {:match-info match

View File

@ -73,8 +73,7 @@
(let [start-of-epoch (:start ev1)
end-of-epoch (:end ev2)]
(when (and (some? start-of-epoch) (some? end-of-epoch))
#?(:cljs (js/Math.round (- end-of-epoch start-of-epoch))
:clj (Math/round ^double (- end-of-epoch start-of-epoch))))))
(- end-of-epoch start-of-epoch))))
(defn run-queue? [event]
(and (fsm-trigger? event)
@ -181,6 +180,9 @@
(defn event-handler? [trace]
(= :event/handler (:op-type trace)))
(defn event-dofx? [trace]
(= :event/do-fx (:op-type trace)))
(defn start-of-epoch?
"Detects the start of a re-frame epoch

View File

@ -358,9 +358,7 @@
render-time (transduce (comp
(filter metam/render?)
(map :duration))
+nil af-traces)
]
;; TODO: where should rounding happen? In metam/elapsed-time?
+nil af-traces)]
{:timing/animation-frame-total total-time
:timing/animation-frame-subs subs-time
:timing/animation-frame-render render-time
@ -371,12 +369,20 @@
:timing/event-processing-time
:<- [:epochs/current-match-state]
(fn [match]
(utils/spy
"eventtiming"
{:timing/event-total (get-in match [:timing :re-frame/event-time])
;;; TODO: calculate handler and effects timing separately
:timing/event-handler (get-in match [:timing :re-frame/event-handler-time])
:timing/event-effects nil})))
(let [{:re-frame/keys [event-time event-handler-time event-dofx-time event-run-time]} (get match :timing)
;; The scope of tracing is:
;; event-run-time
;; event-time
;; event-handler-time
;; event-dofx-time
;; <other stuff>
;; <other stuff>
remaining-interceptors (- event-time event-handler-time event-dofx-time)]
{:timing/event-total event-run-time
:timing/event-handler event-handler-time
:timing/event-effects event-dofx-time
:timing/event-interceptors remaining-interceptors
:timing/event-misc (- event-run-time event-time)})))
(rf/reg-sub
:timing/render-time

View File

@ -80,6 +80,10 @@
[timing-section "handler" (:timing/event-handler event-processing-time)]
[:span "+"]
[timing-section "effects" (:timing/event-effects event-processing-time)]
[:span "+"]
[timing-section "other int." (:timing/event-interceptors event-processing-time)]
[:span "+"]
[timing-section "misc" (:timing/event-misc event-processing-time)]
]]
(doall