Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To Do This With A JOIN?
Message
De
29/12/2005 19:37:57
 
 
À
29/12/2005 16:20:44
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01081733
Message ID:
01081913
Vues:
12
>Fabio!
>
>Instead of using SECONDS() try this...
>
>
SET PROCEDURE TO cusStopWatch.PRG ADDITIVE
>LOCAL m.loStopWatch, m.lcStartBuffer
>m.loStopWatch = CREATEOBJECT("cusStopWatch")
>m.lcStartBuffer = m.loStopWatch.Start()
>FOR m.i = 1 TO 5000
> a=TRANSFORM(m.i)
>ENDFOR m.i
>? "Elapsed time in seconds: " ;
>  + TRANSFORM(m.loStopWatch.Stop(m.lcStartBuffer))
>
>
>Let me know what you think of it!
>
>http://foxridgesoftware.com/Blogs/tabid/84/EntryID/10/Default.aspx
>

Hi Mike, I use these API from over one year in my application;
however the DLL encapsulation of VFP reduces notably the precision.

A small compensation:
DEFINE CLASS cusStopWatch AS Timer

  PROTECTED inTicksPerSecond
  PROTECTED wrapTime
 
  wrapTime = 0

  HIDDEN PROCEDURE Init

	PRIVATE randomName
	STORE SYS(2015) to randomName
   	DECLARE INTEGER QueryPerformanceFrequency IN kernel32 AS (m.randomName) STRING @lpFrequency
   
	LOCAL lcCurrentBuffer

	STORE "        " TO lcCurrentBuffer
	
	? m.randomName+"(@m.lcCurrentBuffer)"
	=EVALUATE(m.randomName+"(@m.lcCurrentBuffer)")
	
	CLEAR DLLS &randomName
	
	THIS.inTicksPerSecond = CTOBIN(LEFT(m.lcCurrentBuffer, 4),"RS") + CTOBIN(RIGHT(m.lcCurrentBuffer, 4),"RS") * 2^32
	
    LOCAL ARRAY laDLLS[1]
	ADLLS(laDlls)

    IF EMPTY(ASCAN(laDLLs,"QueryPerformanceCounter",1,-1,2,15))

		DECLARE INTEGER QueryPerformanceCounter IN kernel32 STRING @lpPerformanceCount

    ENDIF
	
	PRIVATE wrapTime
	STORE 0 TO wrapTime
	FOR k=0 to 1000
		STORE m.wrapTime + this.Stop(this.Start()) TO  wrapTime
	NEXT
	
	this.wrapTime = m.wrapTime/m.k

  ENDPROC

  PROCEDURE Start

	PRIVATE lcStartBuffer

	STORE "        " TO lcStartBuffer

    =QueryPerformanceCounter(@m.lcStartBuffer)

    *The state of the start buffer must be

    *preserved so pass it back. This permits

    *multiple callers to use this same

    *cusStopWatch instance, simultaneously.

    RETURN m.lcStartBuffer

  ENDPROC

	PROCEDURE Stop
	LPARAMETERS tcStartBuffer

	    PRIVATE lcCurrentBuffer
	 	STORE "        " TO lcCurrentBuffer
	    =QueryPerformanceCounter(@m.lcCurrentBuffer)

	    RETURN (		  CTOBIN(LEFT(m.lcCurrentBuffer, 4),"RS")  - CTOBIN(LEFT(m.tcStartBuffer, 4),"RS") ;
	    		+ 2^32 * (CTOBIN(RIGHT(m.lcCurrentBuffer, 4),"RS") - CTOBIN(RIGHT(m.tcStartBuffer, 4),"RS"))) ;
	    		/ m.THIS.inTicksPerSecond - - m.this.wrapTime

	ENDPROC

ENDDEFINE
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform