POV-Ray : Newsgroups : povray.text.tutorials : Tips & tricks: How speed-up calculations in loops - part II : Re: Tips & tricks: How speed-up calculations in loops - part II Server Time: 7 Jul 2008 02:22:14 GMT
  Re: Tips & tricks: How speed-up calculations in loops - part II  
From: Jonathan Wooldridge
Date: 25 May 2002 20:29:51
> >
> >  One of the oldest tricks known, loop unrolling, should speed up as
well.
>
> Nobody likes unrolling 1000000 iterations ;-)
>

Loop unrolling isn't about coding every iteration, for that very reason.
Doing an unroll of a loop reduces the number of passes for the loop.

If you have a million iterations, then there is some overhead for each of a
million passes through the loop.
You can reduce this by a factor of ten, by unrolling the loop ten times
within the loop.

Try timing this:

// Unrolled Script
#local C=1000000;
#while(C)
#local C=C-1;
// Do stuff with C

#local C=C-1;
// Do stuff with C

#local C=C-1;
// Do stuff with C

#local C=C-1;
// Do stuff with C

#local C=C-1;
// Do stuff with C

#local C=C-1;
// Do stuff with C

#local C=C-1;
// Do stuff with C

#local C=C-1;
// Do stuff with C

#local C=C-1;
// Do stuff with C

#local C=C-1;
// Do stuff with C

#end


Post a reply to this message

Copyright 1991-2004 POV-Team™