GithubHelp home page GithubHelp logo

CPU utilization too high about javidx9 HOT 5 OPEN

onelonecoder avatar onelonecoder commented on July 19, 2024
CPU utilization too high

from javidx9.

Comments (5)

OneLoneCoder avatar OneLoneCoder commented on July 19, 2024

Hey, Typically "throttling" would be down to the user - there are several ways to achieve it, the simplest being just calling "this_thread::sleep_for(20ms)" would lock it to 50fps - however, that also locks up user input and everything else.

from javidx9.

gurkanctn avatar gurkanctn commented on July 19, 2024

I had guessed that throttling could be an option in CGE. Thanks for the response.

I think I'll work on throttling, once I can set up Netbeans to compile the header.

Should I close this issue, or keep it open for further discussions on throttling?

from javidx9.

OneLoneCoder avatar OneLoneCoder commented on July 19, 2024

from javidx9.

michaelshmitty avatar michaelshmitty commented on July 19, 2024

Just chiming in here with an observation: I often keep an eye on the CPU usage graph in Visual Studio debug mode in @OneLoneCoder 's videos when he runs the code and I never really see it spike or run the CPU really hot.

@OneLoneCoder brilliant channel, thanks for the great videos and insight.

from javidx9.

giampierosalvi avatar giampierosalvi commented on July 19, 2024

Hi,
I have used the SDL_Delay function to slow down the updates and it worked very well (for example delaying by 10 or 20 milliseconds as suggested by @OneLoneCoder ). Something that I did not manage to achieve is to decide on a constant update period (say 0.02 sec) and use the (0.02-fElapsedTime) * 1000 as an argument to SDL_Delay. Somehow this does not work. I suspect there could be a problem with the granularity of those delay functions that are usually around 10 or 20 ms.

I also want to mention, that this issue can go beyond the CPU getting hot. On one desktop with 8 i7 cores, the examples run fine, although they take ~100% of one of the cores and have a FPS of 1800. However, on an intel nuc, with 4 i5 cores, the examples lock the computer's graphical interface completely (at around 5-600 FPS). I have been running the SDL version on Ubuntu 18.04, but I suspect this could happen on not that powerful windows machines as well. The only way to kill the process was to enter a text based login because the graphical interface was completely unresponsive.

Great job by the way.

from javidx9.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.