Les wrote:
and processor optimizations to achieve faster results. The business of subtraction is one cycle per subtraction, where as fmod is multiple cycles to begin with plus call and return overhead. If the iterative is known to be some small number repeated subtraction may be faster. Only some practical work with the algorithm will tell you the real results.
The compilers I've used put FMOD instructions in line in the code. I haven't looked at the cycle counts in a long time, but I have done hardware performance predictions, and I'm here to tellya, cache hits or misses VASTLY overwhelm the operation of the machine.
The same is true of Floating point operations vs integers. When floats had to be calculated by loops with an integer processor, they were expensive and integers were faster. Now with high speed floating point units, simple float operations are quite fast if done in line. Ditto for doubles. It costs no more to calculate doubles than singles except
Its faster to use floats. I've sped up integer programs by converting to floats and using the FP engine. [snip]
When discussing algorithm timing, only the algorithm being used and its variants can be discussed for realtime applications. This is one reason that benchmarks are basically useless in choosing a processor for real time applications, unless you are using the bench mark algorithm in your specific application.
The first thing to hit is always the algorithm. No amount of cleverness, assembly language, or trickery is going to make a bubble sort any faster than O(N^2). Using heap sort fixes that. [snip]
There are more ways to tackle problems than most of us can imagine. That is why we call upon the local wizards to help us.
Wise words Mike -- p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);} Oppose globalization and One World Governments like the UN. This message made from 100% recycled bits. You have found the bank of Larn. I can explain it for you, but I can't understand it for you. I speak only for myself, and I am unanimous in that!