From: Melchior F. <mf...@ao...> - 2007-09-30 15:14:28
|
* Durk Talsma -- Sunday 30 September 2007: > Thirdly, there is a relation between execution time and listeners, Err ... Nasal listeners trigger Nasal code when the listened-to property is written to. Executed code costs cpu cycles. Anyone surprised? If listeners are used badly and trigger bad code, then this will, of course, hurt the framerate. But that's not because listeners are bad. The problem that I see in the Seneca is that several listeners are used on properties that are written to in every frame, which make no sense. That's a slow replacement for a simple Nasal loop. If you turn on listener logging, then you see a continuous flood of triggered listener code: $ fgfs --aircraft=SenecaII --log-level=debug 2>&1|grep listener ... setting listener #50 in $FG_ROOT/Aircraft/SenecaII/Nasal/SenecaII.nas, line 269 setting listener #51 in $FG_ROOT/Nasal/aircraft.nas, line 216 setting listener #52 in $FG_ROOT/Nasal/aircraft.nas, line 216 setting listener #62 in $FG_ROOT/Aircraft/SenecaII/Nasal/SenecaII.nas, line 437 setting listener #63 in $FG_ROOT/Aircraft/SenecaII/Nasal/SenecaII.nas, line 438 setting listener #69 in $FG_ROOT/Aircraft/SenecaII/Nasal/hsi.nas, line 16 setting listener #79 in $FG_ROOT/Aircraft/SenecaII/Nasal/NLG.nas, line 66 setting listener #80 in $FG_ROOT/Aircraft/SenecaII/Nasal/NLG.nas, line 67 ... trigger listener #50 trigger listener #51 trigger listener #52 trigger listener #62 trigger listener #63 trigger listener #79 trigger listener #80 trigger listener #69 ... That's bad and the reason why I added listener logging. Listener should only be used on nodes that only change occasionally, as I've said numerous times. But I can't *force* people to use them correctly. :-} If you run the bo105 with turned on logging, you won't see a flood of triggered listeners (unless you move the mouse, #21 and #22). You'll only see them if some special "event" happens. Try that. It can't cause any stuttering. m. BTW: the two listener #51 and #52 are attached to light switches, and those aren't usually written to in every frame. In the Seneca they are, though ... :-) |