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; }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章