POV-Ray : Newsgroups : povray.pov4.discussion.general : Caching parsed code : Re: Caching parsed code Server Time
2 May 2024 16:55:21 EDT (-0400)
  Re: Caching parsed code  
From: clipka
Date: 16 Apr 2009 00:05:01
Message: <web.49e6ad4fe0976a9b255d1edc0@news.povray.org>
"nemesis" <nam### [at] gmailcom> wrote:
> Very good answer and solid points, anyway.  Those are all indeed very solid
> benefits of nicely performing interpreters, no doubt.  Thanks for correcting
> me. ;)

You're welcome ;)

BTW, if you ever feel the need to speed up your scene code, here's one that
makes a hell of a difference:


*** Examine your scene file for macros that your scene makes heavy uses of,
*** and copy them to your scene file!


Consider the parsing times for the following code:

#include "rand.inc"
//#macro VRand(RS) < rand(RS), rand(RS), rand(RS)> #end
#declare R = seed(42);
#declare i = 0;
#while (i < 100000)
  #declare V = VRand(R);
  #declare i = i + 1;
#end

On my Windows machine:
Second line commented out: 91.907 seconds (76.843 CPU seconds)
Second line "revived": A blasting 3.562 seconds (3.500 CPU seconds)

Thats ****** 25 TIMES FASTER ******
just because of that single macro call.

Why? Because POV-Ray re-opens the macro's source file each and every time it is
invoked... >_<

On my Linux machine it's not all that bad - probably because Linux doesn't have
such a high OS overhead for opening and closing a file - but still an
impressive factor of 12.


So, standard macro libs are a good thing, but sometimes you better not #include
but copy & paste them :P


Post a reply to this message

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