Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Running exact piece of code alone is 7 times faster in class
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
Running exact piece of code alone is 7 times faster in class
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01009816
Message ID:
01009816
Vues:
68
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 
Zakaria al Azhar
My blog on Actuaris.net
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform