Loop Optimization
CSGNetwork FREE Source Code, Javascript Source, and Code Snippets!
CSGNetwork Custom Search
     Bookmark and Share
á
CSGNetwork
Snippets
Calculators
Top Free Apps
Home
Back



Right click this window and select "view source" in order to copy the source for this script.

Loop Optimization

Standard Faster Fastest

Start Time

End Time

Elapsed Time

Result

Start Time

End Time

Elapsed Time

Result

Start Time

End Time

Elapsed Time

Result


Number Of Loop Iterations


function doStandard()
{
   /* common code */

   for (l=1;l<iterations+1;l++)
   {
      testVal++;
   }

   /* common code */
}
	
function doFast()
{
   /* common code */

   l = iterations;
   do
   {
      testVal++;
   } while (--l);

   /* common code */
}
	
function doFastest()
{
   /* common code */

   n = iterations % 8;
   while (n--)
   {
      testVal++;
   }

   n = parseInt(iterations/8);
   while (n--)
   {
      testVal++;
      testVal++;
      testVal++;
      testVal++;
      testVal++;
      testVal++;
      testVal++;
      testVal++;
   }

   /* common code */
}
	


Loop Optimization

This three stage demo shows the optimization of loop programming. The three different functions are displayed above but we suggest you view the source...



Bookmark and Share
Registered® Trademark™ and Copyrightę 1973 - CSG, Computer Support Group, Inc. and CSGNetwork.Com All Rights Reserved