Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Running exact piece of code alone is 7 times faster in c
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01009816
Message ID:
01009958
Views:
12
I think the message here is not to use an object if procedural code can solve the problem. Unless there is a technical requirement for an object - why go to the trouble?:-)

xBase and procedural VFP code along with efficent DBF structures and indexing schemes are why - when we really try - we can write very fast and appealing applications. VFP and xBase are a mean combination:)

The lower the better - that binding and table buffering stuff is for old men -seek, list view instead of grid, add item instead of row source and hard assign values - and VFP apps scream!

Oh yeah - use PRG classes (they're easier to maintain and implement(!

As for why in this case, I don't know - but thanks for the bench test!

Along time ago a, a Borland engineer gave me some phone time - I asked is there anything wrong with just opening (USE) all the files at the top of the app and just leaving them open?

He said thats what they designed it to do. Performance is better, etc. It also means that the files don't have to be tested to see if they are open (if !USED)) etc. And they can all be closed when the app is exited.

You may have a reason for an ad-hoc DBF open - if there are a lot of DBFs, perhaps a custom datasession-like class could maintain their status, and your app would not have to do whatever kind of search function USED does!

But if you can - just open all the files at the top of the app and leave them open!

Thanks for sharing your test results!
>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
>
Imagination is more important than knowledge
Previous
Reply
Map
View

Click here to load this message in the networking platform