Event Dispatchers Vs Interfaces performance difference?

The questions is whats less resources intensive a large interface or a load of event dispatchers?

TBH, IMHO, you shouldn’t even really be worrying about this unless it’s actually causing any performance issues in your game.

BPIs, EDs, Casting, all have their pros and cons and TBH, everyone should be using each of them.

Zak came out with an awesome stream earlier this year presenting each of them and everyone should probably watch it, it’s a few hours long, but very much worth the time as you’ll learn so much.

Blueprint Communications With Zak

So, now with that out of the way, let’s actually talk about “performance differences”, unless you are willing to actual do a test using each of the methods, you will find very little actual performance hits between each of them. That said, ED would technically be the heaviest IMHO, as it is pretty much just calling out to the whole world even if no one is listening for it. That in itself is a waste. BPIs are almost the same way, again, you would call a BPI and usually you would have the reference of the BPI attached to it, so it is called directly to what you want to (but there’s something in between the two BPs communicating with each other), without so much of a “wasteful” approach since you already know who is listening to that call. Same with Casting, you already know who you are casting to, of course, if it’s null for whatever reason, then that’s a waste, but that is more of a bug and bad design issue, than performance.

In order of “performance differences” from heaviest to cheapest: ED, BPI, Direct Casting.

Again, take that with a grain of salt, as you will most likely never run into an issue with performance when using any of these methods, something else in your design will probably be the cause (such as running heavy math computations or logic on tick).

Event based design is always going to be the most efficient.

Good luck!

2 Likes

ED would technically be the heaviest IMHO, as it is pretty much just calling out to the whole world even if no one is listening for it.

What does this mean? I have no concept of a calling whole world in my programming cookbook, the only thing I can think of is observer pattern, which is about observing only by the name and appeared functionality, under the hood its just arrays of objects to message.