Larian Banner
Previous Thread
Next Thread
Print Thread
Joined: Jul 2014
Location: East Coast
journeyman
OP Offline
journeyman
Joined: Jul 2014
Location: East Coast
Hey all.

Me, Norbyte, and Ameranth were having a discussion earlier today, and it would really be nice if one of the engine developers could clear this up.

What is the performance impact of a custom event (CallFunction, CharacterEvent, ItemEvent, etc)?

Coming from a Node background, I am used to this type of thing being O(1) with respect to other events and O(n) within it's own scope (So it iterates every event of the same type, but not others).

But in the scope of the custom event calls, you kind of have both scenarios. CharacterEvent is, itself, an "event". But you also have an identifier in the parameter which I could see being used as an "event" as well.

So when I have CallFunction('Function1'), and I have 5 event listeners listening for Function1, 2, 3, 4, and 5, am I iterating over each of those listeners and checking what event they are subscribed to, or does the logic know to instantly jump to each listener registered specifically for Function1?

Joined: Sep 2017
Location: Belgium, Ghent
L
stranger
Offline
stranger
L
Joined: Sep 2017
Location: Belgium, Ghent
Hey Sinistralis,

It is indeed the former. It will loop over all OnFunction events and check the parameter of the event to check if it needs to enter or not. In your example it would iterate over all 5 events and only enter the first one. Script events are not the most performance friendly feature of behaviour scripts, mainly due to the different options you have in parameters (locals, globals, and constants) behaving differently.

Joined: Jul 2014
Location: East Coast
journeyman
OP Offline
journeyman
Joined: Jul 2014
Location: East Coast
So then it would be better for me to do a giant if/then/else chain, as opposed to trying to treat Events as a hash table?

I was hoping Norbyte was mistken, but of course he wasn't. Darn.

Appreciate the prompt response as well. Trying to figure out the best way to format string --> skill lookups in my Skill Generator for script support and this has been bothering me a lot.

Last edited by Sinistralis; 08/11/17 10:02 AM.
Joined: Sep 2017
Location: Belgium, Ghent
L
stranger
Offline
stranger
L
Joined: Sep 2017
Location: Belgium, Ghent
A giant if/then/else chain would indeed be faster. Keep in mind that events are instant, which means that if you make enormous events it might impact performance as well. Although I have to admit you really have to abuse it to get that far smile However, one big event will definitely be faster than e.g. 10 linked events calling each other.

Joined: Jul 2014
Location: East Coast
journeyman
OP Offline
journeyman
Joined: Jul 2014
Location: East Coast
So then the solution is somewhere in-between, which is perfect since that's actually sensible with generated code.

My concern is that since ability templates are static, I am planning to make many permutations of them to support different effects, so I'm expecting giant dictionaries of string --> skill conversions since that CAST isnt supported. Talking thousands likely.

It sounds like I want to break these up into categories similar to a binary search then.

Thanks for the help!


Moderated by  Larian_Koala, Larian_KVN 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5