TIMER.Elapsed |
![]() ![]() |
time = TIMER.Elapsed( handle AS HANDLE, resolution AS INTEGER = 1 ) AS REAL
Return the elapsed time. The default is to return the time in Seconds. You can specify a divider to return the elapsed time as a fraction of a second. For example, to return the time in Milliseconds, specify 1000. To return the timer in Microseconds, specify 1000*1000.
Example:
$LIBRARY "MyBASIC2_ExtLib" $INCLUDE "MyBASIC2_ExtLib"
DIM hTimer AS HANDLE
' Open a Timer hTimer = TIMER.Open()
IF hTimer <> MB_INVALID_HANDLE THEN ' Start the Timer TIMER.Start( hTimer ) ' Short Delay of 1.23 seconds SLEEP 1.23 ' Stop Timer TIMER.Stop( hTimer ) ' Display result in Seconds and MilliSeconds PRINT FORMAT( "Elapsed: %1.2f s, %1.0f ms", TIMER.Elapsed( hTimer ), TIMER.Elapsed( hTimer, 1000 ) ), ' Close Timer TIMER.Close( hTimer ) ENDIF
END |