Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Always better to ...?
Message
From
03/03/2000 02:09:53
 
 
To
02/03/2000 19:06:06
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00338054
Message ID:
00341102
Views:
24
>And look at my initial example. I found it in a commercial piece of code. The way I re-wrote the code was certainly easier to read and as I said, it wasn't any faster. I'm trying to say we need the best way to write code.

I think, over time, we're going to see VFP evolve the same way that C/C++ compilers have evolved. It used to be you could get some pretty dramatic improvements in performance under C/C++ by using tricks like inlining, loop unrolling, etc. Modern compilers do that stuff for you automatically so you don't have to worry about it any more.

I seem to remember that in early versions of xBASE, IIF() was a lot faster than IF...ELSE...ENDIF. I used to think this was because there is a one-line C operator that exactly matches the functionality of IIF(). Now I read that people are finding there's not much difference any more. To me, that's evidence that the tokenizer is getting smarter at recognizing equivalent constructs.

Having said all that, the tokenizer will never be perfect and will always lag in low-level C++-style optimizations. Neat high-level language features like named expressions, EVALUATE() and our old pal "&" don't make life any easier for it. So, my theory is that for best performance, make your code and algorithms as "C-like" as possible. Hopefully this will improve the chances that the tokenizer will be able to convert VFP to an efficient C-like equivalent.

On the assumption that the tokenizer doesn't do any C++-style low level optimizations, you could test some of them under VFP:

Loop Unrolling: for loops with small numbers of iterations, instead of
x = 1
FOR x = 1 TO 5 STEP 1
  x = x + 1
ENDFOR

use

x = 1
x = x + 1
x = x + 1
x = x + 1
x = x + 1
x = x + 1
Elimination of Transcendentals: instead of
x = x^4

use

x = x * x * x * x
Inlining: this would be interesting to test with a class hierarchy. If you have a class that is 3 or 4 levels removed from a VFP base class, instead write a VFP base class equivalent with overridden, monolithic methods. Test the time to instantiate a few thousand of them.

Basically, you could make a study of C++ compiler optimization techniques and see which could be applied to VFP.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform