POV-Ray : Newsgroups : povray.text.tutorials : Tips & tricks: How speed-up calculations in loops - part II : Tips & tricks: How speed-up calculations in loops - part II Server Time: 1 Sep 2014 18:34:13 GMT
  Tips & tricks: How speed-up calculations in loops - part II  
From: W³odzimierz ABX Skiba
Date: 11 Feb 2002 11:39:01
Inspired by the result of previous test I've made another benchmark:
How functions speed-up simplest expressions - in this case I wondered what
about loop indexing.

I compared speed of two scripts:

#local dec=function(N){N-1};
#local C=1000000;
#local C=dec(C);


#local C=1000000;
#local C=C-1;

Note difference: first script use function to decrease value of parameter.
Both scripts were started three times on PII 233 with 128 MB (3.5 b 11).
Result: measuring CPU time first script was little faster then second about:
- kernel time: 5,64%
- user time: 11,00%
- total time: 9,38%

Then I compared the same replacement for increased index of loop.

#local inc=function(N){N+1};
#local C=0;
#local C=inc(C);


#local C=0;
#local C=C+1;

In this case there is no difference in speed. It changed from test to test. It
was around +/- 2%. Not big deal in this case.

Additional note: there was the same number of interations but version with
decreasing was faster (20-30%) than version with increasing (probably becouse
of no additional tokens in loop condition).

Any comments ?


Post a reply to this message

Copyright 2003-2008 Persistence of Vision Raytracer Pty. Ltd.