Re: The inaugural VB6 vs dot net test



"Michael C" <mike@xxxxxxxxxx> wrote in message news:OJ9pgUTNIHA.5140@xxxxxxxxxxxxxxxxxxxxxxx

There is no reason why the loop has to go in the same
direction as the bitmap processing. If you look at my
C# code the pointer is incremented seperate to the x
and y variables. I could make x and y count down to
zero without changing any other code. I could make
x count from 1000 to 2024 if I wanted. :-) Just
increment a third variable inside the inner loop.

Yes, I already know that, Michael. And what is more, you obviously already know that I do. But I was repsonding to Ulrich's statement about counting down to zero as opposed to counting up to a specific value in order to save a couple of clock cycles. WTF is the point of doing that if you are then going to include and additional otherwise unnecessary pointer that gets incremented within the loop, which will eat up as least as many clock cycles as you saved, thereby negating your efforts!

When using a 2D array VB must do a "pointer = base + x + y * linewidth" which will be hugely
slower than "inc pointer".

I agree entirely with that, and it is a very good suggestion, and it should speed things up a little. But that is not what I was talking about in my response to Ulrich, as I think you already know. I was specifically responding to Ulrich's statement when he said:

"In my opinion the reason why one could hope that
counting down to 0 makes loops running faster comes
from how the compiler handles those loops".

I wanted him to know that doing so would not in fact save any time at all in this particular case, and that it would in fact make the code run very much slower because doing that (and doing /only/ that) would cause the memory to be accessed in a fashion that failed to take full advantage of the memory cache, a subject which Ulrich did not even mention and which it appeared he did not know about. And of course fixing the "memory cache" problem by adding an additional counter within the loop would negate everything that you gained by your act of counting down to zero instead of counting up.

I really do wish people would read what I post instead of just "coming at me" for reasons that often do not seem to have anything to do with what I actually said, reaosns that I suspect are often more to do with the fact that they just want to wind me up! Ulrich is beginning to fall into that category as well now.

Mike




.



Relevant Pages

  • Re: Sorry if it is not for this forum
    ... it to a pointer that gets incremented, ... increment correspond to? ... Probably where the loop is incremented. ... A code generator / debugger message something like ...
    (comp.lang.c)
  • Re: Sorry if it is not for this forum
    ... If the compiler converts ... it to a pointer that gets incremented, ... increment correspond to? ... Probably where the loop is incremented. ...
    (comp.lang.c)
  • Re: Independent thread fireing events in ATL Service synchronization requirements?
    ... and hence the loop will not execute, ... m_vec itself is not a pointer, so it cannot be NULL for sure. ... >> Did you lock while adding and removing your objects to the list? ... >>> and made my client list a class with synchronization inside ...
    (microsoft.public.vc.atl)
  • Re: The inaugural VB6 vs dot net test
    ... Counting down actually is slower. ... In my oppinion the reason why one could hope that counting down to 0 makes loops running faster comes from how the compiler handles those loops. ... the final value (the loop stops when the loop counter exceeds this value) is stored in a local variable on the stack. ... I've been putting off getting a new machine for a long time now, thinking that they are not yet fast enough to warrant the change, but having seen your figures I think I'm going to get one pretty soon :-) If one core runs so much faster than my own machine then it should fairly fly when running stuff optimized for two cores. ...
    (microsoft.public.vb.general.discussion)
  • Faster 32-bit mul for IAR 78K0 3.34B
    ... Browsed couple days ago throuh the IAR 78K0 C 3.34B libraries and was somehow disapointed to notice that the the 32 bit multiplication was a 'traditional' one, i.e. one that does not use the microcontroller's own multiply instruction. ... ; On the outer loop the 'result' and 'right' bytes are processed; at the same rate, so the hl pointer and pointer + fixed offset; can be used to access a byte from both of the variables. ...
    (comp.arch.embedded)