Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Running exact piece of code alone is 7 times faster in class
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Running exact piece of code alone is 7 times faster in class
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01009816
Message ID:
01009816
Views:
67
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
Next
Reply
Map
View

Click here to load this message in the networking platform