confusing performance

Discussion and feedback on Construct 2

Post » Fri Feb 27, 2015 5:56 pm

I think event 4 would run smoother if you do it with a foreach combined .... not sure, but a similar situation helped with me.
Cause the way it runs now, it tries to check everything simultaneous.


event
for each fam asstroids
sub
fam astroids is overlapping fam astroids
trigger once
action
destroy fam astroids


If I am not mistaken, this will make the checking run consecutively.
Who dares wins
B
50
S
10
G
10
Posts: 1,728
Reputation: 12,895

Post » Fri Feb 27, 2015 6:26 pm

Sorry to be off topic, but your naming conventions are epic. Ass_destroyer.

On topic now!
Limit collision checks. Maybe if objects are off screen you don't care about them? So it might be possible to disable collisions on those objects.

And when objects get a certain range or leave the layout it may be possible to destroy them.

The key is removing objects you don't need. And only doing logic with objects relevant.
B
27
S
8
G
1
Posts: 226
Reputation: 2,835

Post » Fri Feb 27, 2015 9:23 pm

Aphrodite wrote:@nimos100 not sure but AFAIK the debbuger can add an overhead, to be really fair you also have to make them behave the exact same way too to really evaluate a waste between the two (is overllapping does not have to verify if it was already colliding with the same exact instance in the past, while on collision does, also not sure what happens if you have 2 collisions at the same time that occurs between 1 sprite2 and 2 sprite in the same tick between on collision and is overllaping).

but that is interesting.

Im not sure what you mean, what im showing is if you are testing for collisions using the two ways there are. Why waste is important im not sure, because if I increase the number of yellow squares the one using "On collision" will eventually drop in FPS due to amount of objects before the "Is overlapping". So im not looking for exact numbers, just that you can improve performance using one way over the other. Can you explain what you mean differently because Im not sure I understand what you mean?
B
44
S
11
G
2
Posts: 1,177
Reputation: 6,783

Post » Fri Feb 27, 2015 9:24 pm

matrixreal wrote:
nimos100 wrote:Its primarily the "On collision" under setup, try to disable that and let it run again. You shouldn't use "On collision" it is a performance killer :)


and what you suggest to replace "on collision" ?

overlapping ?

and what is the difference between them

Yeah I would replace "On collision" with overlapping due to performance. I don't know what the difference is, but just that you loose performance using "On collision" it can easily be tested, just make a program as in my example.
B
44
S
11
G
2
Posts: 1,177
Reputation: 6,783

Post » Fri Feb 27, 2015 10:53 pm

nimos100 wrote:
Silverforce wrote:I find no difference between On collision or Is Overlap.


That sounds weird, because there is no doubt when I test it that I get a huge difference in performance, do you have any data to show, that would be interesting to see?

Like how many objects etc. would like to see that.


~1400 objects peak, 60% CPU usage. No difference in CPU usage with On Col or Is Overlap. No difference in collision checks per tick.
B
66
S
24
G
19
Posts: 1,752
Reputation: 17,490

Post » Fri Feb 27, 2015 11:31 pm

Silverforce wrote:
nimos100 wrote:
Silverforce wrote:I find no difference between On collision or Is Overlap.


That sounds weird, because there is no doubt when I test it that I get a huge difference in performance, do you have any data to show, that would be interesting to see?

Like how many objects etc. would like to see that.


~1400 objects peak, 60% CPU usage. No difference in CPU usage with On Col or Is Overlap. No difference in collision checks per tick.


That makes no sense, that would kill/slow down my game if there was so many objects with "On collision". Can you do me another favour and run this program, or if anyone else could as well. And just disable "On collision" and enable "Is overlapping" and next try the other way around and screenshot the debug performance window. Because it seems strange that it would be that different. Have you done anything special with your "On collision"?.

Collision_test_capx.capx


The results I get from this is these which uses 1024 objects:

Image
You do not have the required permissions to view the files attached to this post.
B
44
S
11
G
2
Posts: 1,177
Reputation: 6,783

Post » Sat Feb 28, 2015 1:16 am

@nimos100 I get almost the same results as you.
B
32
S
10
G
1
Posts: 14
Reputation: 2,437

Post » Sat Feb 28, 2015 1:35 am

nimos100 wrote:That makes no sense, that would kill/slow down my game if there was so many objects with "On collision". Can you do me another favour and run this program, or if anyone else could as well. And just disable "On collision" and enable "Is overlapping" and next try the other way around and screenshot the debug performance window. Because it seems strange that it would be that different. Have you done anything special with your "On collision"?.


Your capx works as you say.

Give your sprites random bullet movement and then test with On Col vs Is Overlap. I suspect the behavior may change with a sprite that's constantly moving to one that is stationary.

Here's my debug shot.

SN2 Debug.jpg


Each bullet has to check against enemies, each enemy has a separate left & right shield which when depleted, the collision is ignored and checks if it collides with the hull afterwards. Drones also check for collision to enable/disable some movement.

There's some fights that happen off-screen that also needs to be calculated.

I have very low collision checks per tick though (much less than your examples), most of the calculations go for AI position, distance, angle, and lots of variables, so perhaps in my case, any efficiency gains with Is Overlap won't make much of a difference.
You do not have the required permissions to view the files attached to this post.
B
66
S
24
G
19
Posts: 1,752
Reputation: 17,490

Post » Sat Feb 28, 2015 1:48 am

What's interesting is I took your capx, and did the On Col check AFTER a "Every 0.1 seconds" trigger.

Test On Col.jpg


The Col per tick drop as expected as well as CPU usage went down to ~40%. BUT, fps is capped at much lower than 60 fps.

This does not occur for Is Overlap under the same scenario, CPU usage also went down but fps is 60.

There is something fundamentally bottlenecking On Col, causing a higher overhead that is limiting the rendering.

This needs an official input from Scirra. There is a large performance penalty associated with On Col vs Is Overlap.
You do not have the required permissions to view the files attached to this post.
B
66
S
24
G
19
Posts: 1,752
Reputation: 17,490

Post » Sat Feb 28, 2015 2:26 am

This is quite an interesting finding but there is a marked differences between using "is-overlapping" with a "trigger once" compared to using the "on-collision" trigger. I've messed around with the example above to demonstrate this. This version includes drag and drop behavior, so you can select a green or purple square and drag it over the squares of the other color. Because of the squares' dimensions, if you drag a square to the other side of the screen it never stops overlapping at least one of the other types of object. Give it a try and you'll see different results for testing for an overlap and testing for a collision trigger. I added a text object to show the cpu time and fps, in case the debugger added some overhead that muddled the findings.

So, never say never use on-collision - just be aware of what you are asking the engine to test for.
You do not have the required permissions to view the files attached to this post.
B
64
S
16
G
65
Posts: 2,178
Reputation: 41,060

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests