On May 16, 2007, at 09:14 UTC, Frank Condello wrote: > > So - here is the 40 million dollar question - WHY is RB nearly 10 > > times slower than C ? > > Typically the blame is laid on the lack of (or lax) compiler > optimizations.
That blame would be misplaced in this case, though. > RB loops are simply much slower than optimized C > loops, even with all the "speedy" pragmas in place. No, I don't think they are. Looping is pretty fast. But this particular loop is doing two virtual method calls per inner iteration, compared to the C code which is doing no function calls of any sort. That is almost certainly where all the extra time is going. Change your C code to C++ code that calls a virtual method to get a value out of the array, and another to stuff a new value in, and I bet the performance will be similar to RB. > RB also appears to force some superfluous Single<->Double conversions > when you're dealing with single precision data Yes, that's a good point and is no doubt involved too, but I bet it's swamped by the method-call overhead. > In the end I don't really care *why* RB is slower, I (like many > others) would just like to see some drastic improvements... But when you know why it's slower, you know what to ask for. For example, asking for more "compiler optimizations" almost certainly wouldn't help in this case. Loop unrolling, common subexpression elimination, and other standard optimizations aren't going to help a whit with the overhead of two method calls per iteration. It's like asking for a squirt gun to put out a candle while the whole house is in flames. So, assuming I'm right about this (and a Shark session should tell us whether that's the case), and if this particular situation is important to you, then the only optimization to ask for is to special-case and inline the MemoryBlock/Ptr methods. That's a complicated thing to ask for, though -- what if somebody has subclassed MemoryBlock and overridden SingleValue? So the compiler would have to be smart enough to know when that's the case, or else declare that it's not legal. Cheers, - Joe -- Joe Strout -- [EMAIL PROTECTED] Strout Custom Solutions _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
