POV-Ray : Newsgroups : povray.advanced-users : macro question : Re: macro question Server Time
5 Jul 2024 15:14:11 EDT (-0400)
  Re: macro question  
From: Warp
Date: 22 Feb 2008 14:51:39
Message: <47bf27cb@news.povray.org>
Jim Charter <jrc### [at] msncom> wrote:
> I recall something being said here about the relationship of macros and 
> #include files.  As I recall there can be some inefficiency if a 
> frequently called macro resides in a separate file and '#included' by 
> the file doing the calling?  That it is better for it to be resident in 
> the file from which it is called.  I seem to recall it has something to 
> do with memory use?  Anyway I am trying to figure out how this affects 
> things in compounded situations.

  If a #macro is located in another file, calling it is slower than if it's
located in the same file as the calling code. That's because each time the
macro is called that other file is opened, seeked, parsed and closed.
If the macro gets called a lot in a tight loop, the speed impact can be
noticeable.

> For instance what if I have a macro in an #included file but it is only 
> called once.  But IT calls a second macro multiple times.  Where is it 
> best to have the second macro reside?  Is there any advantage to having 
> it in the primary file or is it inefficient, no matter what, since it is 
> called from the #include file?

  I actually don't remember if POV-Ray knows not to re-open the file it's
currently parsing if it happens to be a different file than the main .pov
file.
  Try testing the actual speed differences.

-- 
                                                          - Warp


Post a reply to this message

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