Time a function: Difference between revisions

add BQN
(Time a function in True BASIC)
(add BQN)
Line 699:
REM perform processing
lapsed%=TIME-start%</lang>
 
=={{header|BQN}}==
To execute a function <code>F</code> once and get the amount of time it took to execute with value <code>v</code>, you can do this:
<lang bqn>F •_timed v</lang>
<code>•_timed</code> is a system value that runs <code>F</code> a set number of times and returns the average runtime of the function. Here, since the left argument <code>𝕨</code> is omitted, it is run once.
 
The final result is in seconds.
 
Here are a few example runs:
<lang bqn> {0:1;𝕩×𝕊𝕩-1}•_timed 100
8.437800000000001e¯05
{0:1;𝕩×𝕊𝕩-1}•_timed 1000
0.000299545</lang>
 
 
=={{header|Bracmat}}==
236

edits