Add time macro
This commit is contained in:
parent
073fbcac20
commit
6c4a54745a
2 changed files with 11 additions and 1 deletions
2
sci
2
sci
|
|
@ -1 +1 @@
|
|||
Subproject commit 51961ef24817bb2e33a75946a74c493eac9bcbcf
|
||||
Subproject commit 689a4d018f8f729ff79408b6a43aed631138b19a
|
||||
|
|
@ -6,6 +6,15 @@
|
|||
(defn locking* [form bindings v f & args]
|
||||
(apply @#'locking/locking form bindings v f args))
|
||||
|
||||
(defn time*
|
||||
"Evaluates expr and prints the time it took. Returns the value of
|
||||
expr."
|
||||
[_ _ expr]
|
||||
`(let [start# (. System (nanoTime))
|
||||
ret# ~expr]
|
||||
(prn (str "Elapsed time: " (/ (double (- (. System (nanoTime)) start#)) 1000000.0) " msecs"))
|
||||
ret#))
|
||||
|
||||
(def core-extras
|
||||
{'file-seq file-seq
|
||||
'agent agent
|
||||
|
|
@ -18,5 +27,6 @@
|
|||
'shutdown-agents shutdown-agents
|
||||
'slurp slurp
|
||||
'spit spit
|
||||
'time (with-meta time* {:sci/macro true})
|
||||
'Throwable->map Throwable->map
|
||||
'compare-and-set! compare-and-set!})
|
||||
|
|
|
|||
Loading…
Reference in a new issue