From affb1480cef44969bd4c3f5d0819937214a2f2e6 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 20 Sep 2019 17:31:48 +0200 Subject: [PATCH] :tada: Add namespace for performance measuring and debugging tools. --- frontend/src/uxbox/util/perf.cljc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 frontend/src/uxbox/util/perf.cljc diff --git a/frontend/src/uxbox/util/perf.cljc b/frontend/src/uxbox/util/perf.cljc new file mode 100644 index 0000000000..e03dbe6ff7 --- /dev/null +++ b/frontend/src/uxbox/util/perf.cljc @@ -0,0 +1,19 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) 2015-2019 Andrey Antukh + +(ns uxbox.util.perf + "Performance and debugging tools." + #?(:cljs (:require-macros [uxbox.util.perf]))) + +#?(:clj + (defmacro with-measure + [name & body] + `(let [start# (js/performance.now) + res# (do ~@body) + end# (js/performance.now) + time# (.toFixed (- end# start#) 2)] + (println (str "[perf|" ~name "] => " time#)) + res#)))