Definition: | atom a = time() |
Description: | Return the number of seconds since some fixed point in the past. |
Comments: | Take the difference between two readings of time(), to
measure, for example, how long a section of code takes to
execute.
On Windows the resolution is normally about 0.01 seconds, whereas on Linux the resolution is normally 1 second. To get the current time, use eg format_timedate(date(),"h:mmpm") To display an elapsed time (over 60 seconds) as a human-readable string, use elapsed() (instead of ?). |
Example: |
constant ITERATIONS = 1000000 integer p atom t0, loop_overhead t0 = time() for i=1 to ITERATIONS do -- time an empty loop end for loop_overhead = time() - t0 t0 = time() for i=1 to ITERATIONS do p = power(2, 20) end for ? (time() - t0 - loop_overhead)/ITERATIONS -- calculates time (in seconds) for one call to power |
See Also: | date, format_timedate, elapsed |