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

Post Reply
User avatar
RAMESHBABU
Posts: 591
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

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

Post by RAMESHBABU »

Hi all

Is there any way do it in in FWH ?

Regards,

- Ramesh Babu P
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

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

Post 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
User avatar
RAMESHBABU
Posts: 591
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Post by RAMESHBABU »

Hi Enrico

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

Regards,

- Ramesh Babu P
Post Reply