0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-05 05:49:07 -05:00

Minor improvements on perf ns.

This commit is contained in:
Andrey Antukh 2020-04-16 13:50:29 +02:00 committed by Alonso Torres
parent 484702527e
commit 6adb168ca4

View file

@ -47,6 +47,14 @@
(-persistent! [this] (-persistent! [this]
this))) this)))
(defn tdigest-summary
[td]
(str "samples=" (unchecked-get td "n") "\n"
"Q50=" (.percentile td 0.50) "\n"
"Q75=" (.percentile td 0.75) "\n"
"Q95=" (.percentile td 0.90) "\n"
"MAX=" (.percentile td 1)))
(defn timestamp (defn timestamp
[] []
(js/performance.now)) (js/performance.now))
@ -63,12 +71,8 @@
print-single-summary! print-single-summary!
(fn [name td] (fn [name td]
(js/console.log (str "[measure: " name "] " (js/console.log (str "[measure: " name "] " (tdigest-summary td))))
"samples=" (unchecked-get td "n") "\n"
"Q50=" (.percentile td 0.50) "\n"
"Q75=" (.percentile td 0.75) "\n"
"Q95=" (.percentile td 0.90) "\n"
"MAX=" (.percentile td 1))))
print-summary! print-summary!
(f/debounce (f/debounce
#(.forEach registry (fn [td name] (print-single-summary! name td))) #(.forEach registry (fn [td name] (print-single-summary! name td)))
@ -83,18 +87,13 @@
(uxbox.util.perf/with-measure name (uxbox.util.perf/with-measure name
(apply f args)))) (apply f args))))
(defn on-render-factory (defn on-render-factory
[label] [label]
(let [td (tdigest) (let [td (tdigest)
log (f/debounce log (f/debounce
(fn [phase td] (fn [phase td]
(js/console.log (str "[profile: " label " (" phase ")] " (js/console.log (str "[profile: " label " (" phase ")] "
"samples=" (unchecked-get td "n") "\n" (tdigest-summary td))))
"Q50=" (.percentile td 0.50) "\n"
"Q75=" (.percentile td 0.75) "\n"
"Q95=" (.percentile td 0.90) "\n"
"MAX=" (.percentile td 1))))
300)] 300)]
(fn [id phase adur, bdur, st, ct, itx] (fn [id phase adur, bdur, st, ct, itx]
(conj! td adur) (conj! td adur)