Function MilliSeconds() Foundation

Determines the number of milliseconds that have elapsed since midnight.

Syntax
MilliSeconds() --> nMilliSeconds
Return

The function MilliSeconds() returns a numeric integer value in the range of 0 to 86,399,999. It corresponds to the system time, in the form of the number of milliseconds that have elapsed since midnight.

Description

The environment function MilliSeconds() provides the current system time in milliseconds (one thousandth of a second). The function can be used for code profiling, where the system time is determined at the beginning and the end of a procedure and the elapsed time is calculated.

Examples
Code profiling with MilliSeconds()

// In this example, the time to run two different pieces of code that 
// both create an array filled with random characters is compared using 
// MilliSeconds(). This is a rudimentary form of profiling. 
// The first approach uses AAdd() to populate an empty array in a loop, 
// while the second approach creates a pre-dimensioned array using the 
// Array() function and then updates each existing array item. 

#define ARRAY_ITEMS  200000 

PROCEDURE Main() 
   LOCAL aArray 
   LOCAL nItem 
   LOCAL nMilliSecs1 
   LOCAL nMilliSecs2 
   LOCAL nMilliSecs3 

   nMilliSecs1 := MilliSeconds() 
   aArray      := {} 
   FOR nItem := 1 TO ARRAY_ITEMS 
      AAdd(aArray, Chr(RandomInt(65, 90))) 
   NEXT 

   nMilliSecs2 := MilliSeconds() 
   aArray      := Array(ARRAY_ITEMS) 
   FOR nItem := 1 TO ARRAY_ITEMS 
      aArray[nItem] := Chr(RandomInt(65, 90)) 
   NEXT 

   nMilliSecs3 := MilliSeconds() 
   CLS 
   ? "Time for AAdd() :", nMilliSecs2 - nMilliSecs1 
   ? "Time for Array():", nMilliSecs3 - nMilliSecs2 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.