Nasal for C++ programmers: Difference between revisions

Jump to navigation Jump to search
Line 273: Line 273:
   | if you have a task that consumes 0.01% of the total computational performance, it doesn't matter whether you do it efficient [C++/GLSL] or inefficient [Nasal] - if you make it ten times faster, the framerate won't move a bit, and if you make it a hundred times slower, the framerate won't move either. Given that, you can priorize accessibility and ease of maintenance over execution speed.
   | if you have a task that consumes 0.01% of the total computational performance, it doesn't matter whether you do it efficient [C++/GLSL] or inefficient [Nasal] - if you make it ten times faster, the framerate won't move a bit, and if you make it a hundred times slower, the framerate won't move either. Given that, you can priorize accessibility and ease of maintenance over execution speed.
(To give you a sense of perspective - the typical Nasal subsystem runs a couple of hundred lines per frame. Rendering at high quality runs about 1500 lines for each of your two million pixels every frame and loops over an array containing a good million vertices). That's about a factor of thirty million more operations per unit time. So FG doesn't lean 'heavy' on Nasal in terms of where the work is.
(To give you a sense of perspective - the typical Nasal subsystem runs a couple of hundred lines per frame. Rendering at high quality runs about 1500 lines for each of your two million pixels every frame and loops over an array containing a good million vertices). That's about a factor of thirty million more operations per unit time. So FG doesn't lean 'heavy' on Nasal in terms of where the work is.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=232079#p232079
    |title=<nowiki>Re: Sometime, with Yasim... frame-rate is slow</nowiki>
    |author=<nowiki>Thorsten</nowiki>
    |date=<nowiki>Sat Feb 14</nowiki>
  }}
}}
{{FGCquote
  |you can of course misuse Nasal to do heavy computing duty, in which case it eventually will slow down FG (if you inspect Nasal arrays with millions of entries every frame, it won't be a tiny amount of computation any more). But as long as you use Nasal for things that are not heavy-duty work (i.e. involving loops over thousands of entries, running code triggered by hundreds of listeners at the FDM rate...) the above argument holds.<br/>
<br/>
The bottomline is - you need to optimize framerate by optimizing the part of the code where most performance is burned. Targeting subsystems with insignificant performance is pointless for optimization (still nice conceptually though...).
   |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=232079#p232079
   |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=232079#p232079
     |title=<nowiki>Re: Sometime, with Yasim... frame-rate is slow</nowiki>
     |title=<nowiki>Re: Sometime, with Yasim... frame-rate is slow</nowiki>

Navigation menu