Behaviors Vs Custom

New releases and general discussions.

Post » Sun Dec 07, 2008 3:40 pm

How much faster are the plug-in behaviors? I've been using nothing but behaviors because of the statement "they're optimized in C++", but that's really vague. Even though I choose to do that because I'm in no rush to finish anything, that statement alone could of made me waste a lot of time on them depending on the speed difference. So is there a good speed comparison for say -- A game/cap with 1000 events only custom movement and exact same game with behaviors? Anything above 1.2x-1.5x difference is worth it. Don't have to be a cap, anything hypothetical from someone that knows real speed/code difference is ok.
B
2
S
2
G
4
Posts: 259
Reputation: 1,968

Post » Sun Dec 07, 2008 4:08 pm

Probably no difference whatsoever. It's almost certain your application will spend more time rendering than running behaviors or events. Read this (especially CPU/GPU parallelism).
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Sun Dec 07, 2008 9:01 pm

I'm going to trust your word on this, but I have to be absolutely sure so I have to point out that this isn't a quick prototype and will take years to complete. I'm getting mixed signal by some of the people having slowed down gameplay due to events (loops). Are you absolutely sure even something large and professional will not lag due to events EVER (besides ridiculous nested loops of course)? It's hard to believe, but I'll trust your word for now.

Thanks you.
B
2
S
2
G
4
Posts: 259
Reputation: 1,968

Post » Sun Dec 07, 2008 10:02 pm

If the time of the events being processed is less than the graphics being rendered, the events don't affect the performance at all. In some situations the processing time of events may exceed the rendering time; one of these situations are, as you mentioned, heavy nested loops. However, I'm pretty sure you won't be needing hardcore loops in custom behaviors. Or if you need, the behavior you want is propably so peculiar it isn't implemented in c++ behavior anyway. So, it doesn't really matter, does it?

Edit: Btw. I recently made a .cap where I replaced the Physics behaviour with my custom physics. It actually improved the performance. ([url:2rqjlry3]http://www.scirra.com/phpBB3/viewtopic.php?f=16&t=2075[/url:2rqjlry3])
B
3
S
2
G
5
Posts: 263
Reputation: 2,201

Post » Mon Dec 08, 2008 1:25 am

Drasa is right; if your game happens to be really light on rendering, and really heavy on events, then the events will determine the performance of the game. However, I'm sure this is rare, and that most games spend more time on display. You're suffering from premature optimisation though. It's impossible to tell which your game will be until you make it, in which case trying to determine the fastest way is utterly futile. Make your game whichever way suits you best; if it's slow, find out why, and speed that part up (and that will probably be the renderer). You can't usually pre-empt that process.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Mon Dec 08, 2008 2:02 am

When it comes to keeping your game running smoothly it helps to not go overboard on shaders and other effects.

If you can make your effects before-hand, you should. Like blurring a sprite in Photoshop before putting it into Construct, rather than using the Blur effect or something. Or using plain old color filters instead of Tint Plus when you can get away with it. Obviously you can't always do this, but just be on the lookout for any place you can cut down on GPU time.

Plus, while shaders are nice, a lot of people tend to overuse them anyway. Stacking five shaders on a sprite and topping things off with motion blur doesn't necessarily look good. Keep things slim, keep them subtle. A humble looking, yet good playing game is ten times better than a showcase of shader effects that runs really choppy.

Just my two cents, though.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Dec 16, 2008 9:43 pm

and my two cents: i had an app which would download an array through the http object to a text object. the array was like:[code:3946rl99]1,test,100,200;2,test2,200,200;3,test3,250,200;...........;4000,test4000,200,200[/code:3946rl99]
and after setting the text to a http.response run a loop 4000 times, creating 4000 objects with private variables from the tokenized string (the "1","test","100" and "200" these private variables). This loop lasted about 10 seconds, hanging the game and this was not the http's fault. I'm pretty sure it was the loop's speed.
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Tue Dec 16, 2008 10:25 pm

[quote="ranma":1jy1ltos]and my two cents: i had an app which would download an array through the http object to a text object. the array was like:
and after setting the text to a http.response run a loop 4000 times, creating 4000 objects with private variables from the tokenized string (the "1","test","100" and "200" these private variables). This loop lasted about 10 seconds, hanging the game and this was not the http's fault. I'm pretty sure it was the loop's speed.[/quote:1jy1ltos]

Creating the objects would probably be what was hanging it up there. You can create a program to do 10,000 loops upon a key press, but you'll never notice that it did anything.
Moderator
B
97
S
36
G
19
Posts: 1,584
Reputation: 17,692


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 3 guests