LOOK!
1
第1章
游戏之乐
——游戏中碰到的题目



int main() {
for(; ; {
for(int i = 0; i < 9600000; i++) ;
Sleep(10); }
return 0; }
int busyTime = 10; // 10 ms
int idleTime = busyTime; // same ratio will lead to 50% cpu usage
Int64 startTime = 0; while(true) {
startTime = GetTickCount(); // busy loop
while((GetTickCount() - startTime) <= busyTime) ;
// idle loop
Sleep(idleTime); }
// C# code
static void MakeUsage(float level) {
PerformanceCounter p = new PerformanceCounter("Processor",
热门文档