-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEasyCPUGeekbench.cpp
179 lines (161 loc) · 3.93 KB
/
EasyCPUGeekbench.cpp
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/**
* @file EasyGeekBench.cpp
* @brief: EGB
* @version: 0.3.0a
* @copyright: Zerosoft Company
* @author: Waterdrop142857
* @date: 2023-06-26 13:31:03
*
**/
#include<bits/stdc++.h>
#include<conio.h>
#include<windows.h>
using namespace std;
#define ld long double
#define Limit 983040000
#define R 32.0
ld f(ld x)
{
return sqrt(R * R - x * x);
}
ld V = 0;
long long Status = 0, OldStatus = 0;
long long ReadyCount = 0;
ld Calc(ld l, ld r, long long lim, bool statistics)
{
ld dx = (r - l) / lim;
ld x = l;
ld v;
for (int i = 0; i < lim; i++)
{
v = dx * f((x + x + dx) / 2.0);
x += dx;
V += v;
Status++;
if ((Status - OldStatus) == lim / 10.0 && statistics)
{
char Text[1024];
sprintf_s(Text, 1024, "Finshed: %d %%\n", (int)(Status / (1.0 * lim / 100.0)));
cout << Text;
OldStatus = Status;
}
// if(Status==Limit) break;
}
return V;
}
void About()
{
system("cls");
cout << "Made with CPP,build by GCC\n";
cout << "Developed by Waterdrop142857\n";
cout << "Copyright : Zerosoft Company\n";
system("pause");
}
void SBM()
{
system("cls");
system("title EasyBenchMark - Single-thread Benchmark");
cout << "Preparing for work...\n";
V = 0;
Status = 0;
OldStatus = 0;
cout << "Start work\n";
long long TickA = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
Calc(-R, R, Limit, 1);
long long TickB = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
long long Score = Limit / (TickB - TickA);
cout << "Your Score=" << Score << endl;
cout << V * 2.0 << endl;
system("pause");
}
void ThreadWork(ld l, ld r, long long lim, int NowID, int CntThread)
{
ReadyCount++;
while (ReadyCount != CntThread - 1);
Calc(l, r, lim, 0);
ReadyCount--;
}
void MBM()
{
system("cls");
system("title EasyBenchMark - Mutli-thread Benchmark");
ReadyCount = 0;
V = 0;
Status = 0;
OldStatus = 0;
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
int num = sysinfo.dwNumberOfProcessors;
cout << "Due to the poor technical skills of the developer, displaying progress is not supported when running multi-threaded benchmarks.\n";
long long limOfThread = Limit / num;
long long quyu=(2*R)/num;
for(int i=1;i<num;i++)
{
thread TD(ThreadWork,-R+quyu*(i-1),-R+quyu*i,limOfThread,i,num);
TD.detach();
}
ReadyCount++;
while(ReadyCount!=num);
long long TickA = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
Calc(R-quyu,R,limOfThread,0);
cout<<"It`s Running!\n";
ReadyCount--;
// while(ReadyCount>0);
long long TickB = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
char Text[1024]={0};
sprintf_s(Text,1024,"Used time=%d,TickA=%lld,TickB=%lld,Your Score=%lld\n",TickB-TickA,TickA,TickB,Limit/(TickB-TickA));
cout<<Text;
system("pause");
}
void CST()
{
}
int Menu()
{
system("cls");
system("title EasyBenchMark");
cout << "******************************\n"
<< "* EasyCPUGeekBench *\n"
<< "******************************\n"
<< "* 1.SingleBenchMark *\n"
<< "* 2.MutliBenchMark *\n"
<< "* 3.CPUStabilityTest *\n"
<< "* 5.About *\n"
<< "* 0.Exit *\n"
<< "******************************\n"
;
char ch = 'a';
while (ch < '0' || ch > '5')
{
ch = getch();
}
return (int)(ch - '0');
}
int main()
{
bool flag = 1;
while (flag)
{
int choice = Menu();
switch (choice)
{
case 1:
SBM();
break;
case 2:
MBM();
break;
case 3:
break;
case 4:
break;
case 5:
About();
break;
case 0:
flag = false;
break;
}
}
return 0;
}