Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Running exact piece of code alone is 7 times faster in c
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01009816
Message ID:
01009829
Vues:
10
To improve the speed of Test one, change it to:
*** test 1 :  using class function 
with loTest
	FOR klm = 1 TO 1000000
		.ReadLxTables(cFile)
	ENDFOR 
endwith
That will make it ran faster, but still slower than test 2

>Hi all,
>
>How does it come that if I run an exact piece of code alone is ~ 7 times faster than that I run the code in a function from a class object. I don't understand why it takes so long, I would appreciate if someone could help me optimize the following:
>
>**** speedtest
>LOCAL loTest as ActSymbolen
>cFile = "C:\Actuariaat\Input\gbmgbv.dbf"
>loTest = CREATEOBJECT("ActSymbols" )
>
>time1 = SECONDS()
>
>
>*** test 1 :  using class function
>
>FOR klm = 1 TO 1000000
>
>loTest.ReadLxTables(cFile)
>ENDFOR
>? "using class function         ",SECONDS() - time1 && 15 seconds
>
>SET dataSESSION TO 2
>CLOSE DATABASES ALL
>
>
>time2 = SECONDS()
>
>*** test 2: without using class function
>FOR klm = 1 TO 1000000
>IF !USED("Gbmgbv") THEN
>	USE (cFile) IN 0
>	SELECT "gbmgbv"
>	>ELSE
>	SELECT "gbmgbv"
>ENDIF 	
>ENDFOR
>? "without using class function" ,SECONDS() - time2 && 2 seconds
>
>
>
>
>DEFINE CLASS actSymbols as Session
>
>
>FUNCTION ReadLxTables
>LPARAMETERS cFile
>
>IF !USED("Gbmgbv") THEN
>	USE (cFile) IN 0
>	SELECT "gbmgbv"
>	>ELSE
>	SELECT "gbmgbv"
>ENDIF 	
>
>ENDFUNC
>
>
>
>ENDDEFINE
>
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform