Time a function: Difference between revisions

+ Janet
m (→‎{{header|Factor}}: update to Factor 0.98; add works with template; add USING: ; use output template)
(+ Janet)
Line 1,331:
timespacex '|: 50 50 50 $ i. 50^3'
0.00388519 3.14829e6</lang>
=={{header|Janet}}==
<lang Clojure>(defmacro time
"Print the time it takes to evaluate body to stderr.\n
Evaluates to body."
[body]
(with-syms [$start $val]
~(let [,$start (os/clock)
,$val ,body]
(eprint (- (os/clock) ,$start))
,$val)))
 
(time (os/sleep 0.5))</lang>
{{out}}
<pre>0.500129</pre>
 
=={{header|Java}}==
Anonymous user