0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-26 08:29:42 -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]
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
[]
(js/performance.now))
@ -63,12 +71,8 @@
print-single-summary!
(fn [name td]
(js/console.log (str "[measure: " name "] "
"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))))
(js/console.log (str "[measure: " name "] " (tdigest-summary td))))
print-summary!
(f/debounce
#(.forEach registry (fn [td name] (print-single-summary! name td)))
@ -83,18 +87,13 @@
(uxbox.util.perf/with-measure name
(apply f args))))
(defn on-render-factory
[label]
(let [td (tdigest)
log (f/debounce
(fn [phase td]
(js/console.log (str "[profile: " label " (" phase ")] "
"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))))
(tdigest-summary td))))
300)]
(fn [id phase adur, bdur, st, ct, itx]
(conj! td adur)