cpu的佔用率經過直線表現的代碼

(1)對於繪製50%直線,程序代碼爲: [cpp] view plaincopyprint? #include #include #include int _tmain(int argc,_TCHAR* argv[]) { int busyTime = 10; int idleTime = busyTime*5; __int64 startTime = 0; ::SetThreadAffinityMask(::GetCurrentProcess(),0x00000001); while(true) { startTime = GetTickCount(); //busy loop while((GetTickCount() - startTime) <= busyTime); //idle loop Sleep(idleTime); } return 0; } windows

相關文章
相關標籤/搜索