Time a function: Difference between revisions

→‎{{header|J}}: Corrected misleading comments about variation in requirements.
(→‎{{header|J}}: Corrected misleading comments about variation in requirements.)
Line 45:
=={{header|J}}==
Time and space requirements are tested using verbs obtained through the Foreign conjunction (<tt>!:</tt>). <tt>6!:2</tt> returns time required for execution, in floating-point measurement of seconds. <tt>7!:2</tt> returns a measurement of space required to execute. Both receive as input a sentence for execution.
<br>When the Memoize feature or similar techniques are used, execution time and space can both be affected by prior calculations.
<br>Execution time and space can both be affected by prior calculations. (E.g. space allocation that occurred an earlier test may make subsequent tests much faster than an initial execution.) The order in which tests occur may therefore affect results. Such factors must be taken into account when accuracy of performance measurement is important.
===Example===
Function <tt>f2c</tt> is an iterative calculation of the (2^n)-th number in the [http://www.jsoftware.com/jwiki/Essays/Fibonacci_Sequence Fibonacci sequence].
Anonymous user