Home   Help Search Login Register  

Author Topic: Order of trigger conditions and performance  (Read 1556 times)

0 Members and 1 Guest are viewing this topic.

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Order of trigger conditions and performance
« on: 02 Feb 2010, 18:22:19 »
I'd be interested to know if triggers will cause varying amounts of lag according to the order of their conditions.

For example, suppose I have a trigger of type "West present." Suppose that, most of the time, there will be no West units in the trigger radius. Will the following two trigger condition sets cause the same amount of lag?

Conditions:
Code: [Select]
this && alive player
Conditions:
Code: [Select]
alive player && this
The value "this" will return false most of the time. In that case, no matter whether the player is alive, the trigger conditions cannot be true as a whole. Perhaps, then, the engine saves time by ignoring the second part of the conditions. This will reduce lag, because it can move on to whatever it's supposed to do next.

On the other hand, the player will almost certainly be alive most of the time, so with the second trigger, the engine will be forced to check the other condition as well.

So it seems that the first condition may be less laggy. But perhaps the engine cannot save time by ignoring the rest of the conditions line when the line cannot be true. Does anyone know? This may be useful for improving performance.

Thanks. :cool2:
« Last Edit: 02 Feb 2010, 18:27:10 by RKurtzDmitriyev »
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline Krieg

  • Mission Maker
  • Members
  • *
  • Who dares wins.
Re: Order of trigger conditions and performance
« Reply #1 on: 02 Feb 2010, 18:35:58 »
I do not think that order of conditions will do anything.
It will have same effect, just perhaps a very slight delay in checking the condition.
If you see a light at the end of the tunnel, then it's probably an enemy tank.

Offline dr. seltsam

  • Members
  • *
Re: Order of trigger conditions and performance
« Reply #2 on: 02 Feb 2010, 20:08:35 »
Good question... I would like to know that for myself..
I think the complexity of a partial condition is also a factor for the performance. A possible way to verify your theory would be to set up a test mission, then place your first trigger on the map, use copy and paste to multiplicate this trigger over and over again, maybe 100 or 1000 times. Do this to the point where you clearly notice lag when playing the test mission. Keep the number of placed triggers in your mind. Then do the same with the other trigger type, place the same amount, and check for a difference. Tell us your results here.
:D

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Order of trigger conditions and performance
« Reply #3 on: 23 Feb 2010, 15:59:29 »
So I'll probably get around to testing this eventually, I guess it wasn't too high on my list of things to do. Stay tuned, though. :)

EDIT: Well, I'm trying to cut-and-paste enough triggers to cause lag, but I've tried putting in over 2000 "detected by" triggers and I can't get it to lag! Why can't lag show up if and only if you want it to?  >:( As I add triggers it's lagging the mission editor (with all those icons) much faster than the mission itself! Stay tuned.  :P
« Last Edit: 23 Feb 2010, 16:44:30 by RKurtzDmitriyev »
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: Order of trigger conditions and performance
« Reply #4 on: 24 Feb 2010, 04:19:55 »
The type of conditional checks do not matter. It is the execution of the code which places such high demand on the processor. Each trigger is checked twice a second and thus placing them will not induce the lag. But if several of those trigger conditions are met at once OR you have several looping scripts which execute code at the same time, lag will become evident.

The lag you are experiencing from the amount of triggers placed in the editor is probably a graphics processor problem from having to regenerate all of those icons every time you move the screen. That same lag does not show in game because the images of the triggers do not show.

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Order of trigger conditions and performance
« Reply #5 on: 25 Feb 2010, 00:21:19 »
Quote
The type of conditional checks do not matter. It is the execution of the code which places such high demand on the processor. Each trigger is checked twice a second and thus placing them will not induce the lag.

So, in other words, the engine can check triggers almost instantaneously, much faster than it can execute them? This seems to contradict what I read elsewhere.

Maybe I'll try placing thousands of triggers with complex conditions rather than "this." Macguba in the thread above says that those poll much faster than twice/second.
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: Order of trigger conditions and performance
« Reply #6 on: 27 Feb 2010, 04:24:10 »
No, I do not debate that triggers poll every 0.5 seconds. I am saying that there is no strain on the amount of triggers that have to poll every 0.5 seconds. Checking for conditions is the same as reading code, it is blazing fast. But when the processor has to execute the code afterwards, it has to access, blocks of code from various other files or resources or what have you which effects the overall speed of the processing. Each execution adds one more level of slow down and thus the more that is executed at once, the slower your processor becomes. The more RAM you have the more information your processor can store for quicker access, which is like grabbing a tool from your toolbelt rather than having to dig through your tool box to look for it.

Trigger execution certainly has a profound effect on processor speed, though simply reading through the conditions do not.