Page 1 of 1

Is there a way to test the elapsed time in milli seconds?

Posted: Fri Mar 17, 2006 12:37 pm
by RAMESHBABU
Hi all

Is there any way do it in in FWH ?

Regards,

- Ramesh Babu P

Re: Is there a way to test the elapsed time in milli seconds

Posted: Fri Mar 17, 2006 1:32 pm
by Enrico Maria Giordano

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL i, j, a[ 10 ]

    FOR i = 1 TO 10
        FOR j = 1 TO 10000; j = j; NEXT
        a[ i ] = MILLISECS()
//        a[ i ] = GETTICKCOUNT()
    NEXT

    WQOUT( a )

    RETURN NIL


STATIC FUNCTION MILLISECS()

    LOCAL cPerformanceCount := SPACE( 8 )

    LOCAL nCount

    STATIC nFreq

    QPCOUNTER( cPerformanceCount )

    nCount = BIN2NUM( cPerformanceCount )

    IF nFreq = NIL
        QPFREQUENCY( cPerformanceCount )
        nFreq = BIN2NUM( cPerformanceCount )
    ENDIF

    RETURN ROUND( nCount / nFreq * 1000, 0 )


STATIC FUNCTION BIN2NUM( cBinData )

    LOCAL nLow  := BIN2L( LEFT( cBinData, 4 ) )
    LOCAL nHigh := BIN2L( RIGHT( cBinData, 4 ) )

    IF nLow < 0; nLow += 4294967296; ENDIF

    RETURN nLow + 4294967296 * nHigh


DLL32 STATIC FUNCTION QPCOUNTER( cPerformanceCount AS LPSTR ) AS BOOL;
      PASCAL FROM "QueryPerformanceCounter" LIB "kernel32.dll"

DLL32 STATIC FUNCTION QPFREQUENCY( cPerformanceCount AS LPSTR ) AS BOOL;
      PASCAL FROM "QueryPerformanceFrequency" LIB "kernel32.dll"

DLL32 STATIC FUNCTION GETTICKCOUNT() AS DWORD;
      PASCAL FROM "GetTickCount" LIB "kernel32.dll"
EMG

Posted: Sun Mar 19, 2006 3:24 am
by RAMESHBABU
Hi Enrico

Thank you very much for your set of functions to measure the
milli seconds. :D

Regards,

- Ramesh Babu P