Home > Architecture > Loop optimization technique

Loop optimization technique

January 20th, 2006

Post Views: 273

We always wanted to make your application process more efficiently. If you have been using for loops in your application more often in the following fashion:

for(int i=0;i< =counter;i++)
{
……..
}

Then replace it with:

for(int i=counter-1;i>=0;i–)
{
……..
}

Now compare your application performance, you will be astonished how fast your application behave.

The myth in that assembly language has cx counter that is used to execute loops. Every time assembly encounters a loop, it is executed in the decrement fashion instead of increment. That’s why the second loop design works faster than the first one.

Architecture

  1. No comments yet.
  1. No trackbacks yet.


Copyright © 2006-2011 W@rfi