|
V+ 12.4 Release Notes |
TIMER (timer_number)
Return the current time value (in seconds) of the specified system timer.
The accuracy and resolution of the timers vary according to which timer is selected. DOUBLE variables should be used to achieve maximum resolution. See the Details section below.
timer_number Real value, variable, or expression (interpreted as an integer) that specifies the number of the timer to be read. The value must be in the range -3 to 15.
Timers 1 through 15 have a resolution of one millisecond and have a maximum count of > 2.E+009. They can be used to measure an interval of up to 596 hours from when they were set by the TIMER instruction.
Timer 0 returns the number of seconds since the V+ system was started, with a resolution of 1 millisecond and a maximum count of about 2.E+009. It is only valid during the first 596 hours of system operation and should generally not be used.
Timer -1 returns the low 24 bits of the time since the V+ system was started, in counts of 16 milliseconds. It can be used to compute time intervals of up to 74 hours.
Timer -2 returns the low 24 bits of the time since the V+ system was started, in counts of 1 millisecond. It can be used to compute time intervals of up to 4.6 hours.
Both Timers -1 and -2 may be used when an application does not wish to use timers 1 through 15, or needs more than 15 timers.
Timers -1 or -2 may be used as follows:
AUTO start_time, interval, scale scale = 62.5 ;Set scale = 1000 for TIMER(-2) start_time = TIMER(-1) ... interval = ((TIMER(-1)-start_time) BAND ^HFFFFFF)/scaleIn V+ 11.2 and later, timer -3 provides a better method for computing such intervals provided that a DOUBLE value can be used.
Timer -3 returns the time in seconds since V+ was started as a 52-bit double-precision value. This timer has a resolution of 1 millisecond and a maximum count of > 4.E+015. It can be used to compute intervals of > 100,000 years. It is used similarly to timers -1 and -2 except that DOUBLE variables are required and no BAND operation or scale factors are used.
AUTO DOUBLE REAL start_time, interval start_time = TIMER(-3) ... interval = TIMER(-3)-start_timeThe type of V+ variable used in time computations affects the maximum interval that can be computed with full resolution. Standard REAL variables have only 24 bits of resolution, which limits the time interval to 16,777,216 (224) counts. This limit corresponds to about 4.6 hours for millisecond timers and 74 hours for 16-millisecond timers. DOUBLE REAL variables have 52 bits of precision so the full resolution of the various timers is stored.
The following example shows how the TIMER instruction and real-valued function can be used to time the execution of a subroutine:
TIMER 1 = 0 ;Set timer to zero CALL test.routine() ;Call the subroutine TYPE "Elapsed time =", TIMER(1)," seconds"TIMER timer_number = time_value (program instruction)
|
Please submit comments to: techpubs@adept.com |