CPU usage question

Post » Sun Oct 22, 2017 12:38 pm

My game uses Webfonts, performance is absolutely fine so long as you only set the text once and not every tick.
B
15
S
4
G
1
Posts: 87
Reputation: 1,180

Post » Mon Oct 23, 2017 7:50 am

Hi @Ashley / others :)

Since there is still no official answer, I'll re-ask the question hoping someone might spot it.

Taking the cpu heavy text fields out of the equation, I've tried setting up a barebones project that is using a single 'sine' behaviour on a single sprite.

This alone make the cpu go to around 85% on an iPhone SE. This is from reading the remote preview debug info.

Is this reading correct? If it is than there is not much that can be done to optimise your game, if you rely on some of these behaviours.
B
55
S
23
G
9
Posts: 183
Reputation: 9,596

Post » Mon Oct 23, 2017 8:18 am

I’m running my first project on an iPhone 6s+ - I have 3 instances of webfonts (the stand-in logo, the hi-score and current score - both updated every tick) the reset of the app is made up of very simple graphics. My CPU ussageis also around 85/90%.
B
14
S
7
G
9
Posts: 225
Reputation: 6,300

Post » Mon Oct 23, 2017 11:22 am

@Ninjadoodle - as the manual notes, the reading is a timer-based estimate. There's a lot of stuff that can throw it off. For example if the CPU throttles down in to a low-power mode to save battery, it will take longer to do the same work. This makes the CPU take longer to process a tick, and since our CPU reading is a timer-based estimate, the timer covers more time, and makes for a higher reading. So you can end up with a high CPU reading even when the device is using say 10% capacity, because it's done something like clocked itself down by 10x to save battery.

This happens a lot, and I've also noticed it in C3's GPU measurements too. If you run a benchmark the measurements will steadily increase towards close to the 100% mark, then suddenly jump way down as the workload gets more intense. The device didn't suddenly have less work to do - it's always been increasing - it probably just jumped up to a higher performance mode to compensate for the workload. We can't access the CPU/GPU usage directly in a browser, so we have to estimate it from timers, and this is one of the drawbacks of timer-based measurement: we really measure "how long did the work take" rather than the more accurate "what proportion of capacity is being used".

I made a quick demo and ran it on an iPad Air 2 with iOS 11. It does start at around 83% CPU. However if you touch the screen a bit, the CPU drops down to ~10%. This is probably because it starts in a low-power mode doing work slowly to save battery, but when you interact with it then iOS boosts the priority of the app, powers up the CPU, which does the work faster, so a shorter time is measured, so the engine's CPU measurement drops down.

So yes, it's normal. It's not really using up all your CPU, it's just saving battery. Since we have to use timer-based measurements, you will only get reliable measurements when driving the device to its highest performance tier.
Scirra Founder
B
415
S
248
G
92
Posts: 25,291
Reputation: 200,966

Post » Tue Oct 24, 2017 7:33 am

Hi @Ashley

Thank you very much for the detailed answer, I appreciate you taking the time to do this.

I understand the issues you've described, but can't help feeling that the 'cpu usage reading' is not much use, when it is so strongly affected by other factors.

I was worried that a lot of the behaviours were really that cpu hungry, but was confused as my game still ran 60fps.

Thanks again!
B
55
S
23
G
9
Posts: 183
Reputation: 9,596

Post » Tue Oct 24, 2017 2:34 pm

Ninjadoodle wrote:Hi @Ashley

Thank you very much for the detailed answer, I appreciate you taking the time to do this.

I understand the issues you've described, but can't help feeling that the 'cpu usage reading' is not much use, when it is so strongly affected by other factors.

I was worried that a lot of the behaviours were really that cpu hungry, but was confused as my game still ran 60fps.

Thanks again!


It is really useful in a relative sense though. If you group everything up, you can see which events are relative CPU hogs and optimize those.

One of the goals in mobile performance optimization is to keep the CPU clock speed low, reducing heating and improving battery life. By monitoring group CPU usage, I was able to significantly reduce device heating on mobile.
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
61
S
22
G
27
Posts: 456
Reputation: 19,336

Post » Fri Nov 03, 2017 6:56 am

But why use a text object at all? You could use a variable or arrays to store the text that should be displayed. Your way seems like a very unlogical way of doing it. Sounds like you should just use spritefonts instead which is exactly what you need without the unnecessary events. It works just like the text object but a lot more optimized. Just set the text with one event and you're good to go.



When I started using Construct that ( using text ) seemed the quickest way to do it. I'm sure there are other ways, but if it works why bother. I was already using it to display scores and debug stuff, so it was simple to just grab info from there instead of creating arrays and other stuff. Now that I have already done it, just copy paste into another game.

No, sprite fonts may not work with this. Using effects like glow, bevel and whatever else on text in Photoshop just looks better.
B
37
S
19
G
7
Posts: 151
Reputation: 6,929

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests