Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Alphabetic numbering system
Message
 
 
To
08/01/1999 20:57:39
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00174074
Message ID:
00174358
Views:
27
Erik,

I got about a 25% increase in speed total in what I tried with your code. The two changes that gained the most were elimination of the ^ and removing the intermediate stores. With a good optimizing C compiler those intermediates never see real memory, they stay in the registers. In VFP thousands of lines of machine code are executing for that loop, and VFP has no optimizer. I think the only time you'd see an intermediate store improving performance is if it's a common expression that is used more than once in the loop (for example your 26^i used twice in the 10to26 loop), but I always tend to hand optimize those anyway.

This is all a moot point if you aren't calling the functions a few hundred thousand times, because the difference isn't real big. And code readability is most usually important. But we each have different measurements of that. I think the code is more readable without the intermediate stores. I'm biased though by the high performance and realtime systems I've worked on in the past.

>I looked at rewording the routine after I noticed how long it was taking in the trace window. I came up with something similar to what you posted, but decided to revert to the original layout because I thought the code read better. (On looking at your code though, I think they just read differently depending on how you originally approached the problem.)
>
>I question your second point about storing intermediate values though. From my experience storing intermediate values has little to know affect on speed (depending, of course on how excessive you get). Sometimes storing intermediate values can increase speed.
>
>The way that I have always figured it worked internally (correct me if I am wrong) is that even if you are not storing the value in code, VFP is internally. If you store and reference a value as opposed to letting VFP try and figure out itself if it needs to recalculate, this can often result in better performance.
>Most of this doesn't directly apply to the routine in question, but this does:
>I never sacrifice readability for marginal performance gains.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform