-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPUline.cpp
More file actions
38 lines (34 loc) · 723 Bytes
/
CPUline.cpp
File metadata and controls
38 lines (34 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <Windows.h>
#include <stdlib.h>
#include <math.h>
using namespace std;
int main()
{
const double SPLIT = 0.01;
const int COUNT = 200;
const double PI = 3.14159265;
const int INTERVAL = 300;
DWORD busy[COUNT];
DWORD idle[COUNT];
double half = INTERVAL/2;
double radius = 0;
int j = 0;
DWORD starttime = 0;
for(int i = 0; i < COUNT; i++)
{
busy[i] = (DWORD)half + sin(PI*radius)*half;
idle[i] = (DWORD)INTERVAL - busy[i];
radius += SPLIT;
}
while(true)
{
j = j%COUNT;
starttime = GetTickCount();
while(GetTickCount() - starttime < busy[j])
;
Sleep(idle[j]);
j++;
}
return 0;
}