# Does amount of Events impact speed?

### » Tue Apr 18, 2017 8:41 pm

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.
B
34
S
9
G
4
Posts: 253
Reputation: 5,367

### » Tue Apr 18, 2017 9:05 pm

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.
B
16
S
7
Posts: 190
Reputation: 1,823

### » Tue Apr 18, 2017 9:18 pm

Moot wrote: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.
B
34
S
9
G
4
Posts: 253
Reputation: 5,367

### » Tue Apr 18, 2017 10:47 pm

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.
B
51
S
24
G
70
Posts: 1,196
Reputation: 41,370

### » Tue Apr 18, 2017 10:49 pm

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.

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.
B
178
S
50
G
206
Posts: 8,686
Reputation: 127,715

### » Wed Apr 19, 2017 8:57 am

Thanks people.
B
34
S
9
G
4
Posts: 253
Reputation: 5,367

### » Wed Apr 19, 2017 9:24 am

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.
or in this thread Archer Devlog
B
49
S
22
G
19
Posts: 1,135
Reputation: 14,812

### » Wed Apr 19, 2017 10:04 am

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.
Scirra Founder
B
414
S
245
G
92
Posts: 25,206
Reputation: 200,353

### » Wed Apr 19, 2017 5:49 pm

Havok wrote: I'm wondering if it will be a Moot point

B
16
S
7
Posts: 190
Reputation: 1,823

### » Wed Apr 19, 2017 10:26 pm

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?
B
42
S
16
G
6
Posts: 544
Reputation: 7,701

Next