SFML community forums

Help => General => Topic started by: slotdev on April 26, 2012, 10:21:21 am

Title: High CPU use
Post by: slotdev on April 26, 2012, 10:21:21 am
We've just started using SFML on yet another new type of hardware, which is a 1.6Ghz Intel Atom (with 1GB RAM), running XP Embedded. My game, which on my Core i3 laptop uses ~3% CPU when idle (and still rendering ~30fps) takes the CPU on the Atom to 97%.

So...what to do? I use a Sleep with 3ms every pass of my game loop, so it's giving a lot of time back to the CPU...I don't think changing this will make any difference. We even reduce the frame rate to 5fps at many points when waiting for user input, to reduce the load from CPU as much as possible.

Does anyone have any ideas? I'd really appreciate some input :-)

Thanks
Ed
Title: Re: High CPU use
Post by: eXpl0it3r on April 26, 2012, 10:29:18 am
I'm not sure how you reduce the display to 5fps, can you ellaborate?

Also do you use sf::RenderWindow::setFramerateLimit(int)?
This should call sleep() on its own an guarantee a framerate around the given number. Thus if you don't do anything it will sleep longer and if you do a lot of calculation it will sleep less.

Additionally does the PC with 97% CPU usage have a proper graphics card?
Title: Re: High CPU use
Post by: Laurent on April 26, 2012, 10:31:54 am
You should first profile your app, it's hard to optimize when you don't know what to optimize :)

Then if it's something not too specific to your app, you should be able to reproduce it in a minimal example that we can test.
Title: Re: High CPU use
Post by: slotdev on April 26, 2012, 10:34:38 am
Hi

Yes we use SetFramerateLimit, this is set to 60fps by default, and then we have our own internal frame timer, and we just update the screen based on this timer. I guess I could call SetFramerateLimit too with the fps we're currently doing?

Thanks