mirror of
https://github.com/penpot/penpot.git
synced 2025-07-23 03:57:22 +02:00
⚡ Add general performance micro optimizations
This commit is contained in:
parent
78f62cc5e1
commit
b7e1e54a92
4 changed files with 45 additions and 25 deletions
|
@ -48,7 +48,7 @@
|
|||
(defn duration
|
||||
[o]
|
||||
(cond
|
||||
(integer? o) (.fromMillis Duration o)
|
||||
(number? o) (.fromMillis Duration o)
|
||||
(duration? o) o
|
||||
(string? o) (.fromISO Duration o)
|
||||
(map? o) (.fromObject Duration (clj->js o))
|
||||
|
@ -239,6 +239,25 @@
|
|||
(when v
|
||||
(let [v (if (datetime? v) (format v :date) v)
|
||||
locale (obj/get locales locale)
|
||||
f (-> (.-formatLong ^js locale)
|
||||
(.date v))]
|
||||
(dateFnsFormat v f #js {:locale locale})))))
|
||||
f (.date (.-formatLong locale) v)]
|
||||
(->> #js {:locale locale}
|
||||
(dateFnsFormat v f))))))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Measurement Helpers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn tpoint
|
||||
"Create a measurement checkpoint for time measurement of potentially
|
||||
asynchronous flow."
|
||||
[]
|
||||
(let [p1 (.now js/performance)]
|
||||
#(duration (- (.now js/performance) p1))))
|
||||
|
||||
(defn tpoint-ms
|
||||
"Create a measurement checkpoint for time measurement of potentially
|
||||
asynchronous flow."
|
||||
[]
|
||||
(let [p1 (.now js/performance)]
|
||||
#(- (.now js/performance) p1)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue