Jump to content
  • Advertisement
Sign in to follow this  
Mafioso

Game loop uses only 20-40% of CPU

This topic is 3034 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So the main problem that I have only 30 fps in my game and CPU is 20-40% used, is there are way to increase CPU usage, to render more FPS?

Share this post


Link to post
Share on other sites
Advertisement
What does your gameloop look like? Do you have more than one core? Do you have vsync enabled or some other framerate enforcer?

Share this post


Link to post
Share on other sites
I think you have it the wrong way around. Does your game have a step() function? You ought to be able to increase framerate in there.

Share this post


Link to post
Share on other sites
Hi Mafioso,

what language are you using? Frameworks? Engines?

Are you maybe using 20 - 40% of CPU power but one core with 100%?

eg.
1st Core = 100%; 2nd core = 0%; 3rd core = 0%; 4th core = 5 - 20% (for the operating system) => 25 - 30% CPU usage.

--GWDev

Share this post


Link to post
Share on other sites
My game loop:


MSG msg;
startTime = timeGetTime();

while(TRUE)
{
double currentTime = timeGetTime() - lastTime;

if (currentTime < 0)
{
update = false;
}
else
{
update = true;
frameCount++;
lastTime = timeGetTime();
}
FPS = frameCount / ((timeGetTime() - startTime) / 1000);

if (update == true)
{
renderFrame();
SnakeMovement(0,0);
SnakeMovement(1,31);
}
}


Share this post


Link to post
Share on other sites
Quote:
Original post by GWDev
Hi Mafioso,

what language are you using? Frameworks? Engines?

Are you maybe using 20 - 40% of CPU power but one core with 100%?

eg.
1st Core = 100%; 2nd core = 0%; 3rd core = 0%; 4th core = 5 - 20% (for the operating system) => 25 - 30% CPU usage.

--GWDev


I'm using C++ Direct 9.0 and WinSock, no frameworks or engines. My pc have 2 cores, but all my CPU usage is 20-40%

Thanks for helping [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by mrchrismnh
I think you have it the wrong way around. Does your game have a step() function? You ought to be able to increase framerate in there.


What means step() function? Can't find it on MSDN documentation.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mafioso
Quote:
Original post by GWDev
Hi Mafioso,

what language are you using? Frameworks? Engines?

Are you maybe using 20 - 40% of CPU power but one core with 100%?

eg.
1st Core = 100%; 2nd core = 0%; 3rd core = 0%; 4th core = 5 - 20% (for the operating system) => 25 - 30% CPU usage.

--GWDev


I'm using C++ Direct 9.0 and WinSock, no frameworks or engines. My pc have 2 cores.

Thanks for helping [smile]
1. Make sure that v-sync is off (you're using D3DPRESENT_INTERVAL_IMMEDIATE, not D3DPRESENT_INTERVAL_DEFAULT)
2. Make sure that you're not blocking in any Winsock calls (I.e. use select() to poll, and / or set FNBIO on the socket)
3. If you want to use more than 50% of a dual core CPU you'll need to run multiple threads. Since you're doing networking, it may be suited to run on a separate thread.

Share this post


Link to post
Share on other sites
Quote:
Original post by Antheus
Dual core?
Quad core?
Hyperthreading?


I have Dual Core. I'm not sure about Hyperthreading, because I don't know how to use it, so I think I didn't use it [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!