joyride icon indicating copy to clipboard operation
joyride copied to clipboard

Add `time` macro

Open PEZ opened this issue 9 months ago • 0 comments

Joyride doesn't come with the time macro. nbb has this:

(defmacro time
  "Async version of time."
  [expr]
  `(let [start# (cljs.core/system-time)
         ret# ~expr
         ret# (js/Promise.resolve ret#)]
     (nbb.core/await
      (.then ret# (fn [v#]
                    (prn (cljs.core/str "Elapsed time: "
                                        (.toFixed (- (cljs.core/system-time) start#) 6)
                                        " msecs"))
                    v#)))))

Anyway, @borkdude thinks SCI should have it, so that is probably the best way to fix this.

PEZ avatar Oct 30 '23 16:10 PEZ