Caché Basic Reference
Timer

 Server:docs1 Instance:LATEST User:UnknownUser

 [ Home ]  >  [ Caché Development References ]  >  [ Caché Basic Reference ]  >  [ Caché Basic Functions ]  >  [ Timer ] Go to: Example See Also Search:

Returns the number of seconds that have elapsed since midnight UTC.
Synopsis
`Timer`
Arguments
none
Description
Timer is commonly used to determine elapsed time. However, because Timer resets to zero at midnight UTC, a robust timer program cannot simply subtract the start time from the end time.
Timer returns the elapsed number of seconds since midnight in Coordinated Universal Time (UTC), which is independent of time zone. Consequently, Timer provides a time value that is uniform across time zones. This may differ from the local time value. The Timer returned value is a decimal numeric value that counts the time in seconds and fractions thereof. The number of digits in the fractional seconds may vary from zero to nine, depending on the precision of your computer’s time-of-day clock. On Windows systems the fractional precision is three decimal digits; on UNIX® systems it is six decimal digits. Timer suppresses leading and trailing zeroes. If the fractional portion is exactly zero, the trailing decimal point is also suppressed.
Example
The following example compares two Timer function values to determine the time it takes to iterate a For...Next loop 50 times. In this example, each iteration through the loop prints out the ASCII character set. (For the purpose of demonstration, a Sleep statement is included so that the elapsed time is not smaller than the available fractional precision.) The before and after timer values are compared, and the elapsed time displayed. The Else clause is provided to handle the midnight reset situation.
```Dim StartTime,EndTime,TimeIt
StartTime = Timer
For I = 1 To 50
Sleep .05
x = 32
Print I
For N = 1 To 94
Print Chr(x)
x = x + 1
Next
Println ""
Next
EndTime = Timer
Println "start time: ",StartTime
Println "end time: ",EndTime
If EndTime >= StartTime Then
TimeIt = EndTime - StartTime
Else
EndTime = EndTime + 86400
TimeIt = EndTime - StartTime
End If
Println "elapse time: ",TimeIt
```

See Also

 Copyright © 1997-2017, InterSystems Corp. [Back]    [Home]    [Top of Page]   [Next] Build: Caché v2017.1 (792) Last updated: 2017-03-20 19:02:20 Source: RBAS_ftimer.xml