Which is better for CPU?

Discussion and feedback on Construct 2

Post » Wed Mar 18, 2015 3:33 pm

Which is better to do "every 0.3 secs > move 50" or "every 0.03 secs > move 5" for CPU usage. Or is there little difference?
B
7
Posts: 18
Reputation: 307

Post » Wed Mar 18, 2015 3:37 pm

The every 0.3 will be more cpu friendly.

But the 0.03 will be more smooth.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Wed Mar 18, 2015 5:54 pm

lennaert wrote:But the 0.03 will be more smooth.

i think 0.03 cant be really smooth because one tick at 60 FPS is 0.0167 seconds, but please correct me if im wrong

but on topic, its generally less cpu intensive if you call your event less often, for your example it doesnt matter at all how much pixels the image is moved in one action, its the same process for 1 or 50 pixels or even 500, what matters is how often its done
B
38
S
11
G
5
Posts: 485
Reputation: 5,340

Post » Wed Mar 18, 2015 6:12 pm

fldr wrote:
lennaert wrote:But the 0.03 will be more smooth.

i think 0.03 cant be really smooth because one tick at 60 FPS is 0.0167 seconds, but please correct me if im wrong

but on topic, its generally less cpu intensive if you call your event less often, for your example it doesnt matter at all how much pixels the image is moved in one action, its the same process for 1 or 50 pixels or even 500, what matters is how often its done



with more smooth I meant the movement.
Instead of jumping 50 pixels every 0.3 seconds, moving just 5 pixels every 0.03 would seem more smooth to a degree.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Wed Mar 18, 2015 6:48 pm

yeah that for sure! youre absolutely wright! didnt want to say it was wrong what you said, just the particular 0.03 seconds seemed to me wont get a real "smoothnes", or am i wrong there?
B
38
S
11
G
5
Posts: 485
Reputation: 5,340

Post » Wed Mar 18, 2015 6:57 pm

Scirra Founder
B
387
S
230
G
87
Posts: 24,248
Reputation: 192,238

Post » Wed Mar 18, 2015 7:18 pm

fldr wrote:yeah that for sure! youre absolutely wright! didnt want to say it was wrong what you said, just the particular 0.03 seconds seemed to me wont get a real "smoothnes", or am i wrong there?


Nah your right

... although, we could argue and nitpick that with some extra application of dt in the movement section, he could have gotten even smoother :lol:
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Wed Mar 18, 2015 8:16 pm

yeah thats wright, guess i have to much time for procrastination :D
B
38
S
11
G
5
Posts: 485
Reputation: 5,340

Post » Thu Mar 19, 2015 9:34 am



I used to optimize every event and design the logic ground up taking into account weaker & slower JS performance on mobiles.. worked wonders.

Then I started making an even more complex game, ala. Homeworld complexity, I thought since the target is desktops, let's ignore optimizations and see what happens.. half way through combat fleet AI testing, I ran into 96% CPU use (single threaded) and it stuttered, dropping frames.

Quickly realizing how bad it was to ignore optimizations of logic ground up, I revisited everything and put in optimizations and its been much better, at a more reasonable ~50% peak CPU usage.

Fleet battle scenario:
https://drive.google.com/file/d/0BzblvP ... NseTg/view

Draw calls takes only 5-10% of the CPU usage, the rest is pure logic.

It is ALWAYS good practice to optimize logic, regardless of the target device. Thinking it runs 60 fps is good enough is bad because someone with a weaker machine, like notebooks, ultrabooks or older PCs will struggle.
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,614

Post » Thu Mar 19, 2015 10:28 am

@Silverforce - it's entirely sensible to guide optimisations based on measurements. However I would be amazed if anyone could measure any significant performance difference for the question asked in this thread. Changes on that level are really not important.
Scirra Founder
B
387
S
230
G
87
Posts: 24,248
Reputation: 192,238

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests