|
|
Le 18-04-21 à 11:03, Bald Eagle a écrit :
> I'm well aware that there are complaints about speed, and the topics of parallel
> processing and gpu have been addressed.
> I'm also aware that SDL is not a compiled language.
> This is a legitimate inquiry (sprinkled with White whine) to further educate
> myself and the non-POV-team/developer community.
>
>
>
> Just for my own information, I'm wondering why POV-Ray is so painfully slow to
> process non-rendering information (parse time).
>
> I'm asking, because I converted some of Paul Nylander's Mathematica code for the
> reaction-diffusion algorithm to SDL, and although I knew beforehand that it has
> a fair amount of looping through a 'large' array (160x120), I was still somewhat
> amazed and dismayed that it was as slow as it was.
>
> This is thrown into even starker contrast when I run the reaction-diffusion code
> from Coding Challenge into Processing - which somehow manages to crank out
> results on a 700 x 500 grid at 60 frames per second (that's what's in the code,
> and the default speed - no idea if this is actual)
> I'm pretty sure Processing is as high a level language as SDL, and it's not
> compiled... so what IS the difference?
>
> Is there some sort of bottleneck or fundamental reason that the programmatic
> handling of data is so slow in comparison to other languages?
>
> Thanks
>
>
Parsing is strictly iterative and can only use a single thread.
If you use any macro in a loop, it will get expanded and parsed each
time it's used.
If that macro is in an include file, that file will get opened and read
each time the macro is invoked. EVERYTHING before the macro definition
need to be read and skipped. Example : If you use any colour
manipulation macro from colors.inc, they are located at the end, forcing
the parser to read the whole include every time they are used. It get
much worse if a macro also use another macro from another include...
Cure : Copy any macro that is used in a loop into your main file. Remove
any comment located within the macro, or move them before the macro
definition.
It takes time to skip over comments : The parser need to read each
character until it find the next non-comment one. Try to place your
comments out of any loops, especially the inner loops when you have
nested loops.
Long variables names are nice to make your code understandable and easy
to maintain, but take longer to parse. In any loop, use short names
making sure that they are properly commented/explained out of the loop.
The gain is small, but quickly add up in a loop.
Post a reply to this message
|
|