-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
55 lines (46 loc) · 1.2 KB
/
main.c
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
const char rocket[] =
" ^ \n\
/^\\\n\
|-|\n\
| |\n\
| |\n\
|F|\n\
|P|\n\
|S|\n\
/| |\\\n\
/ | | \\\n\
| | | |\n\
`-\"\"\"-`\n\
";
int fps = 0, averageFps[10], averageFpsIndex = 0, inputTime;
printf("enter the testing time is seconds: (max value: 10) \t");
scanf("%d", &inputTime);
time_t lastTime = time(NULL), endTime = lastTime + inputTime;
while (lastTime < endTime) {
printf("--------FPS--------\n");
printf("\033[31m");
printf("\t%d\n", fps);
printf("\033[0m");
fputs(rocket, stdout);
time_t currentTime = time(NULL);
if (currentTime - lastTime >= 1) {
lastTime = currentTime;
averageFps[averageFpsIndex] = fps;
averageFpsIndex++;
fps = 0;
}
fps++;
system("clear");
}
int sum = 0;
for (int i = 1; i < averageFpsIndex; ++i) sum += averageFps[i];
printf("Average FPS: ");
printf("\033[31m");
printf("%d\n",sum / (averageFpsIndex - 1));
return 0;
}