🐛 Fix performance macros disabled in production mode

This commit is contained in:
Alejandro Alonso
2025-10-16 11:46:43 +02:00
committed by Alonso Torres
parent d933e91c6c
commit 8e8d46b314

View File

@@ -45,13 +45,13 @@
(defmacro begin-measure
[measure-name]
(when enabled?
(when (enabled?)
(let [measure-name (str/concat measure-name "::begin")]
`(.mark js/performance ~measure-name))))
(defmacro end-measure
[measure-name & [detail]]
(when enabled?
(when (enabled?)
(let [begin-name (str/concat measure-name "::begin")
end-name (str/concat measure-name "::end")
detail `(cljs.core/js-obj ~@(mapcat (fn [[k v]] [(name k) v]) detail))
@@ -62,7 +62,7 @@
(defmacro with-measure
"Measures the time of a function call. This should only be called in synchronous functions"
[[measure-name detail] body]
(if-not enabled?
(if-not (enabled?)
body
`(let [_# (begin-measure ~measure-name)
result# ~body