Game loop uses only 20-40% of CPU

Started by
16 comments, last by 21st Century Moose 13 years, 8 months ago
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?
Advertisement
What does your gameloop look like? Do you have more than one core? Do you have vsync enabled or some other framerate enforcer?
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.
"It's like naming him Asskicker Monstertrucktits O'Ninja" -Khaiy

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
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);		}	}
Dual core?
Quad core?
Hyperthreading?
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]
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.

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.
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]

This topic is closed to new replies.

Advertisement