Re: Fast array indexing with pointers

Tech-Archive recommends: Fix windows errors by optimizing your registry




I am using a for-loop and array indexing to perform a muliply add routine.
I
would like to try and speed the loop up by using pointers instead of array
indexing.

On top of the other answers already given, did you do any measurements to
see how
much time this routine is actually using?
I have worked on some numerical algorithms myself, and my experience is that
the best thing you can do (in most cases) is to keep your code as simple as
possible and then let the optimizer
take care of it.

doing all sorts of tricks to save one or 2 instructions can even make your
programs much slower because you might hamper the optimizer from doing its
job.

Unless this routine gets called continuously for 100 times a second, manual
optimization is not even worth it.
use 'GetTickCount' to count the number of ms that you algorithm takes to
complete. then you can decide if it makes sense to optimize.
since this time will be very short in your case you should count the time it
takes to do this 5000 times or so and then average it. if you only measure 1
iteration the results will be unusable because of context switches and
scheduling.

--

Kind regards,
Bruno.
bruno_nos_pam_van_dooren@xxxxxxxxxxx
Remove only "_nos_pam"


.