Does amount of Events impact speed?

0 favourites
  • 12 posts
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • Generally, does the amount of events impact speed?

    Say you have an action that takes 10 Events to do a certain task...maybe lets say something simple like movement and flipping animations etc.

    If you do that same task in a different way and it takes 5 events, does it speed up the game or does it not really matter much when run?

    In other words does the task (what it's performing) have more impact than the number of events?

    Does the amount of sub events impact speed more than just usign a regular event.

    I know this is kindof a general question but i'm trying to test some things w.r.t performance.

  • I'm guessing there is a difference in performance depending on the amount of events you have, but a difference between 5 and 10 events is probably insignificant. The amount and type of actions you have in each event has a lot to do with it too.

  • I'm guessing there is a difference in performance depending on the amount of events you have, but a difference between 5 and 10 events is probably insignificant. The amount and type of actions you have in each event has a lot to do with it too.

    That's exactly what I am trying to make a conclusion on.

    Is the 10 Events with 1 action in each faster than 5 events with 2 actions each? I'm wondering if it will be a Moot point

    and then in actual fact be the same in performance wise.

    I know I'm over simplifying it but I suppose we can make the numbers say 100 events with 1 action each vs 50 events with 2 actions each.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I think the actual actions that are performed is more relevant in determining the processing speed than the number of events/sub-events.

    I also would put a priority on creating events that can easily be scaled; ie, constructing your events so that it allows you to expand the game. If you focus too much on trying to combine everything together, then you'll begin to get stuff entangled and it will be difficult to expand your game. It took me a long time figuring out how important this is.

  • It depends on what the events are doing.

    If you are checking collisions on hundreds of objects then that particular event will slow down the system, especially if it's doing it every tick.

    If all its doing is setting an objects opacity to the same value, then no it won't adversely degrade fps, .....unless you have hundreds if not thousands of instances doing that.

    Adding extra events to stop it setting the opacity don't add any overhead either.

    Unless you have hundreds if not thousands of instances doing that every tick.

    So basically, adding extra events to stop unnecessary repetition are the way to go.

  • Thanks people.

  • Another good tip.

    Good practice is to have as few events running as possible. Place events in groups and close the groups when they are not needed. Constantly having the event sheet check through all the conditions will get heavier the more you have.

    For example: If you have an event checking the distance between objects, and none of these objects are visible on screen at the moment you can pretty much disable disable those events by putting them in a group and disable the group altogether.

    That's one of the major optimizations i did for my mobile games that gave me a lot more bang for the buck.

    I had a quite a lot of stuff constantly checking in the background every tick, after optimizations like that, basically my game was actually really using about 20% of all the events at any given moment, instead of checking through all of them. A lot of small things add up.

    So for now i always think like this.

    The best code is no code at all.

    You'll have much better performance the less your game is doing every single tick. Closing groups, and using every X seconds instead of every tick can boost performance quite a bit. Especially on mobile where you have pretty limited CPU power.

  • There's no clear answer to your question: 5 events could be slower, the same or faster than 10 events. It depends on too many things. The only thing that matters, and the only thing you should ever do, is make actual measurements. If you don't make measurements, you're just making things up.

  • I'm wondering if it will be a Moot point

  • Correct me if I'm wrong but I got the impression Havok is asking if there's a performance overhead to events themselves, regardless of conditions. Like, will a thousand empty events running every tick bog things down for instance?

  • Depending on the particular event, it can, or it might not. There is no solid answer. A single event running physics or pathfinding on a ton of objects may cause more impact than a thousand empty events.

    That is why the best answer is to test it and see. If you can't benchmark/measure any significant difference, then it isn't worth worrying about.

    If you want a straight answer, I'll give you an unofficial one - No, number of events or sub events does not impact speed. You're welcome to show me a specific case where it does, and I will say you're right, but most likely it is a case already covered in https://www.scirra.com/blog/83/optimisa ... -your-time.

    And if you don't trust Scirra for some reason here are other articles to read. It is common advice across all platforms.

    http://www.flounder.com/optimization.htm

    http://www.joshbarczak.com/blog/?p=580

    http://wiki.c2.com/?PrematureOptimization

    Basically it comes down to this: If you can't tell for certain yourself if it makes a difference, and you are unable to create a situation where you are able to tell it does make a difference, and end up having to ask someone else if it does or not... then the information is of absolutely no practical use.

    Edit: As for what really does matter, in terms of deciding how to organize your events, is readability and how the events fit together logically (your own logic). I might be able to combine 10 events down to 1, but it will take a lot of effort and if I need to change anything later it might be a pain. It might also be harder to remember what I was going for in the first place.

  • Yes it does matter, if you're doing something like using the same conditions over and over.

    Example:

    Event 1 - Bullet is overlapping wall, turn on particle effect

    Event 2 - Bullet is overlapping wall, play sound

    Event 3 - Bullet is overlapping wall, destroy.

    Doing something stupid as that is going to be 3 times heavier than just putting all the actions under the same condition. Above example will check overlap 3 times. Every time you use the same condition again it has to check for it again. So it's generally better to use less conditions like:

    Event 1 Bullet is overlapping wall, turn on particle effect, play sound, destroy.

    Much better than checking same conditions over and over, like above example.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)