Fix event processing time

This commit is contained in:
Daniel Compton 2018-01-30 16:52:20 +13:00
parent 7af2532d55
commit 0994626814
3 changed files with 38 additions and 5 deletions

View File

@ -26,6 +26,7 @@ This version requires re-frame 0.10.4 to make use of the newly added Event panel
* Layer 2/3 calculations are more accurate now. We now use the last seen layer level when a subscription runs, to inform it's layer level if it was created or destroyed.
* View namespaces that are ignored are no longer shown when showing traces for all epochs.
* Distinguish between subscriptions that return `nil` values and those that haven't run yet.
* Timing panel not showing elapsed event processing time.

View File

@ -2,7 +2,7 @@
(:require [mranderson047.re-frame.v0v10v2.re-frame.core :as rf]
[mranderson047.reagent.v0v7v0.reagent.core :as r]
[cljs.tools.reader.edn]
[day8.re-frame.trace.utils.utils :as utils]
[day8.re-frame.trace.utils.utils :as utils :refer [spy]]
[day8.re-frame.trace.utils.localstorage :as localstorage]
[clojure.string :as str]
[goog.object]
@ -548,9 +548,21 @@
reset-state))))
sub-state
new-matches))
timing (mapv (fn [match]
(let [epoch-traces (into []
(comp
(utils/id-between-xf (:id (first match)) (:id (last match))))
filtered-traces)
start-of-epoch (nth epoch-traces 0)
finish-run (or (first (filter metam/finish-run? epoch-traces))
(utils/last-in-vec epoch-traces))]
;; Note, sometimes we still end up with a nil elapsed time here, look into more
{:re-frame/event-time (metam/elapsed-time start-of-epoch finish-run)}))
new-matches)
new-matches (map (fn [match sub-match] {:match-info match
:sub-state sub-match}) new-matches subscription-match-state)
new-matches (map (fn [match sub-match t] {:match-info match
:sub-state sub-match
:timing t}) new-matches subscription-match-state timing)
all-matches (reduce conj previous-matches new-matches)
retained-matches (into [] (take-last number-of-epochs-to-retain all-matches))
app-db-id (get-in db [:app-db :reagent-id])

View File

@ -224,6 +224,21 @@
:else (get (:matches-by-id epochs) current-id))]
match)))
(rf/reg-sub
:epochs/current-match-state
:<- [:epochs/epoch-root]
:<- [:epochs/match-ids]
(fn [[epochs match-ids] _]
(let [current-id (:current-epoch-id epochs)
match (cond
(nil? current-id) (last (:matches-and-subs epochs))
(< current-id (first match-ids)) (first (:matches-and-subs epochs))
;; This case seems impossible, but can happen if the user filters out
;; an event that they are 'on'.
(> current-id (last match-ids)) (last (:matches-and-subs epochs))
:else (get (:matches-by-id2 epochs) current-id))]
match)))
(rf/reg-sub
:epochs/current-event-trace
:<- [:epochs/current-match]
@ -322,9 +337,14 @@
[start end] (first (drop (dec frame-number) frames))]
(metam/elapsed-time start end))))
(rf/reg-sub
:timing/event-processing-time
:<- [:epochs/current-match-state]
(fn [match]
(utils/spy "match" match)
(get-in match [:timing :re-frame/event-time])))
#_(rf/reg-sub
:timing/event-processing-time
:<- [:traces/current-event-traces]
(fn [traces]