|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Please don't answer with "nothing new. I use it so long". I use it so long, too.
I just want to make benchmark and result is some kind of tips&trick thing.
I want to compare speed between macro calculation, inline calculation and
function calculation. All tests are performed with currrent (10) beta of POV-Ray
3.5 for Windows (icl) on PII 233 with 128 MB and. Here are scripts:
// SCRIPT 1 - Macro calculation
#macro Calc(X,Y)sin(X)+Y+cos(X*Y)^2+1/3#end
#local MaxX=500;
#local MaxY=500;
#local X=0;
#while(X<MaxX)
#local Y=0;
#while(Y<MaxY)
#local D=Calc(X,Y);
#local Y=Y+1;
#end
#local X=X+1;
#end
// SCRIPT 2 - inline calculation
#local MaxX=500;
#local MaxY=500;
#local X=0;
#while(X<MaxX)
#local Y=0;
#while(Y<MaxY)
#local D=sin(X)+Y+cos(X*Y)^2+1/3;
#local Y=Y+1;
#end
#local X=X+1;
#end
// SCRIPT 3 - function calculations
#local Calc=function(X,Y){sin(X)+Y+cos(X*Y)^2+1/3};
#local MaxX=500;
#local MaxY=500;
#local X=0;
#while(X<MaxX)
#local Y=0;
#while(Y<MaxY)
#local D=Calc(X,Y);
#local Y=Y+1;
#end
#local X=X+1;
#end
// RESULTS
// SCRIPT 1 - macro calculations
CPU time used: kernel 20.79 seconds, user 74.22 seconds, total 95.01 seconds
// SCRIPT 2 - inline calculations
CPU time used: kernel 9.74 seconds, user 47.34 seconds, total 57.08 seconds
// SCRIPT 3 - function calculations
CPU time used: kernel 8.95 seconds, user 37.78 seconds, total 46.74 seconds
ABX
Post a reply to this message
|
|
| |
| |
|
|
From: Warp
Subject: Re: Tips & tricks: How speed-up calculations in loops
Date: 28 Jan 2002 11:59:21
Message: <3c558368@news.povray.org>
|
|
|
| |
| |
|
|
You should also compare the speed when the macro is defined in an include
file instead of the same scene file (in theory it should be much slower).
It would also be interesting to see what happens if the function is defined
in an external include file (AFAIK there should not be speed difference, but
who knows?).
--
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 28 Jan 2002 11:59:21 -0500, Warp <war### [at] tagpovrayorg> wrote:
> You should also compare the speed when the macro is defined in an include
> file instead of the same scene file (in theory it should be much slower).
> It would also be interesting to see what happens if the function is defined
> in an external include file (AFAIK there should not be speed difference, but
> who knows?).
I will do it. At this moment I fill sick and I'll be absent one week probably
(depends on doctor's decision).
ABX
Post a reply to this message
|
|
| |
| |
|
|
From: JRG
Subject: Re: Tips & tricks: How speed-up calculations in loops
Date: 30 Jan 2002 17:33:49
Message: <3c5874cd@news.povray.org>
|
|
|
| |
| |
|
|
> I will do it. At this moment I fill sick and I'll be absent one week probably
> (depends on doctor's decision).
Does this mean that I'll have to wait some more for those spaghetti?
Hope you feel better soon.
--
#local j=text{ttf"arial""JRG".2,0}#local J=0;#while(J<10)#local R=0;#while
(R<2)#local G=0;#while(G<1)#if(inside(j<R,G.1>))object{j scale.025translate
<R-1G-J/20J/-40+2>pigment{rgb<9J>}}#debug"O"#else#debug" "#end#local G=G+
.025;#end#local R=R+.05;#debug"\n"#end#local J=J+1;#end// JRG
Home: http://digilander.iol.it/jrgpov //New: Kitchen scene WIP
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
wrote:
> I want to compare speed between macro calculation, inline calculation and
> function calculation. All tests are performed with currrent (10) beta of POV-Ray
> 3.5 for Windows (icl) on PII 233 with 128 MB and. Here are scripts:
Here is result of extended test made after Warp's suggestions:
Total CPU time used was measured in seconds.
The same machine, script and calculation was used.
Every scene was started 3 times. result was averaged.
Two loops as earlier but with max. 1000 so, it was 1.000.000 use of calculation:
external macro - 1026,47 [s]
internal macro - 350,73 [s]
calculation on-place - 221,15 [s]
external function - 179,62 [s]
internal function - 178,68 [s]
ABX
Post a reply to this message
|
|
| |
| |
|
|
From: Warp
Subject: Re: Tips & tricks: How speed-up calculations in loops
Date: 5 Feb 2002 11:52:55
Message: <3c600de6@news.povray.org>
|
|
|
| |
| |
|
|
: external macro - 1026,47 [s]
: internal macro - 350,73 [s]
As I thought.
This means that if you are using some #included macros in really tight
loops which are taking lots of time to parse, you'd better just copy-paste
the used macros from the include file to the beginning of the current file
to gain parsing speed.
: external function - 179,62 [s]
: internal function - 178,68 [s]
This was also predictable and good to know: Functions in #included files
are not slower than functions in the current file, so they can be used
without worries.
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|