Time a function: Difference between revisions

m
→‎{{header|REXX}}: added a modern timing, built a better comment. -- ~~~~
m (→‎{{header|REXX}}: removed some superflous blank lines. -- ~~~~)
m (→‎{{header|REXX}}: added a modern timing, built a better comment. -- ~~~~)
Line 1,084:
<br>there is a way to easily query the host (VM/CP) to indicate how much CPU time was used by your userID.
<br>The result can be placed into a REXX varible (as an option).
<lang rexx>/*REXX program to show the elapsed time for a function (subroutine). */
call time 'E'
call silly
say 'function SILLY took' format(time("E"),,2) 'seconds.'
/* │ */
 
/* ┌────────────────┘ */
/* The above 2 for the FORMAT function displays the time */
/* with 2 decimal digits (past the decimal point). Using */
/* a 0 /* (zero)The above would round2 the timefor tothe wholeFORMAT seconds.function displays the time */
/* with 2 decimal digits (past the decimal point). Using */
/* a 0 (zero) would round the time to whole seconds. */
exit
/*──────────────────────────────────SILLY subroutine────────────────────*/
 
silly: procedure /*subroutine chewschew up some CPU time doing some silly stuff.*/
do j=1 for 100000
a.j=random() date() time() digits() fuzz() form() xrange() queued()
end
return</lang>
'''output''' (when using a computer built in the 20th century:
'''output'''
<pre>
function SILLY took 3.54 seconds.
</pre>
'''output''' (when using a computer built in the 21st century:
<pre>
function SILLY took 0.44 seconds.
</pre>