POV-Ray : Newsgroups : povray.general : optimisation of functions - how to? : Re: optimisation of functions - how to? Server Time
30 Jul 2024 02:29:38 EDT (-0400)
  Re: optimisation of functions - how to?  
From: Thorsten Froehlich
Date: 20 Jan 2010 08:34:57
Message: <4b570681@news.povray.org>
On 20.01.10 13:13, makc wrote:
> Thorsten Froehlich<tho### [at] trfde>  wrote:
>> You are overlooking it: What you want is "select"
>
> Wow thanks, that does give some noticeable boost (and so hope to it).
>
> Re sum/prod, can't see how that is different, except that I can put expression
> as argument vs it being function body. Is it faster that way?

Indeed, the overhead is somewhat lower than for a function call (due to the 
internal structure of the function VM). What you need to know is that you 
can you the local variable as the end value, i.e.

sum(i, ... compute variable i ..., i, ... your function here ...)

That way the sum function iterates exactly once. This works because i is 
initialized as soon as the start value is computed, hence it can be used by 
the end value computation, which is only computed once, too.

	Thorsten


Post a reply to this message

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