Skip to content

Commit f06cbd0

Browse files
authored
Update corebench.py
1 parent e0fcde6 commit f06cbd0

1 file changed

Lines changed: 105 additions & 9 deletions

File tree

corebench/corebench.py

Lines changed: 105 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def get_file_hash():
7272

7373
return sha256.hexdigest()
7474

75-
def sendForAuth(cpu_name, core_count, thread_count, ram, single, mcore, mthread, gflops, full, os_name, version, key):
75+
def sendForAuth(cpu_name, core_count, thread_count, ram, single, mcore, mthread, gflops, fullLoad, full, os_name, version, key):
7676
server_ip = "https://submit.corebench.me/submit"
7777

7878
headers = {
@@ -90,6 +90,7 @@ def sendForAuth(cpu_name, core_count, thread_count, ram, single, mcore, mthread,
9090
"multi_core": mcore,
9191
"multi_thread": mthread,
9292
"gflops": gflops,
93+
"full_load": fullLoad,
9394
"overall_score": full,
9495
"os_name": os_name,
9596
"version": version
@@ -122,6 +123,7 @@ def apiCheck(apiKey):
122123
"multi_core": "",
123124
"multi_thread": "",
124125
"gflops": "",
126+
"full_load": "",
125127
"overall_score": "",
126128
"os_name": "",
127129
"version": ""
@@ -137,9 +139,9 @@ def apiCheck(apiKey):
137139
response = requests.post(server_ip, json=data, headers=headers)
138140
return response
139141

140-
def upload_and_return_status(name, core_count, thread_count, memory, score, mcore, mthread, gflops, final, distro, version, key):
142+
def upload_and_return_status(name, core_count, thread_count, memory, score, mcore, mthread, gflops, fullLoad, final, distro, version, key):
141143
try:
142-
response = sendForAuth(name, core_count, thread_count, memory, score, mcore, mthread, gflops, final, distro, version, key)
144+
response = sendForAuth(name, core_count, thread_count, memory, score, mcore, mthread, gflops, fullLoad, final, distro, version, key)
143145
status_code = response.status_code
144146
message = response.text
145147

@@ -305,7 +307,7 @@ def distroColour():
305307
quit()
306308

307309
#UPDATE THIS WITH EVERY VERSION
308-
version = "1.4.9"
310+
version = "1.5.0"
309311
#UPDATE THIS WITH EVERY VERSION
310312

311313
endLoad = True
@@ -326,7 +328,7 @@ def loadingScreen():
326328
f"Eating all {memRaw}MB of RAM...", "Overclocking...", "Deleting main.py...", "Always remember to remove the French language pack!",
327329
f"Not much of a {osName} fan myself, but you do you...", f"Welcome back {hostname}.", f"Haha! Got your IP! Seriously! {localIp}", "I use Arch btw",
328330
"I use Core btw", "Over 6GHz!", "Bringing out the Intel Pentium...", "Gathering texel fillrate...", "Collecting frames...", "No fake frames here!",
329-
"Changing boot order...", "Imagine if you were using this on Windows lol", "Still held prisoner by Replit.", "It's dangerous to go alone.",
331+
"Changing boot order...", "Imagine if you were using this on Windows lol", "No longer held prisoner by Replit!", "It's dangerous to go alone.",
330332
"All your bench are belong to us.", "GPU bench coming soon. Maybe.", "Unused RAM is useless RAM. Give some to me."]
331333
message = messages[random.randint(0,len(messages)-1)]
332334

@@ -872,6 +874,98 @@ def get_physical_core_ids():
872874

873875
return sorted(physical_cores.values())
874876

877+
#Full Load Test SUBROUTINES
878+
def fp_benchmark(data_chunk):
879+
total = 0
880+
881+
for i in data_chunk:
882+
if i == 0:
883+
continue #funny bug lol
884+
885+
total += math.sin(i) * math.cos(i) + \
886+
math.log(i + 1) * math.sqrt(i) + \
887+
math.exp(i % 10) + \
888+
math.factorial(i % 10) + \
889+
math.tan(i / 3) * math.atan(i / 2) + \
890+
math.pow(i, 2) + \
891+
math.sqrt(math.fabs(math.sin(i))) + \
892+
math.log(math.fabs(math.cos(i) + 1)) + \
893+
math.sin(i * 2) * math.cos(i * 2)
894+
895+
return total
896+
897+
def full_load_benchmark(func, data, num_cores, iterations=5):
898+
times = []
899+
chunk_size = len(data) // num_cores
900+
901+
chunks = [data[i * chunk_size:(i + 1) * chunk_size] for i in range(num_cores)]
902+
903+
#chunks = [
904+
# data[0:250], # Chunk for core 0
905+
# data[250:500], # Chunk for core 1
906+
# data[500:750], # Chunk for core 2
907+
# data[750:1000] # Chunk for core 3
908+
#]
909+
910+
for _ in range(iterations):
911+
start_time = time.perf_counter()
912+
913+
with multiprocessing.Pool(processes=num_cores) as pool:
914+
results = pool.map(func, chunks)
915+
916+
end_time = time.perf_counter()
917+
918+
times.append(end_time - start_time)
919+
920+
return sum(times) / len(times)
921+
922+
def run_full_load_benchmark(num_cores, data, iterations=5):
923+
chunk_size = len(data) // num_cores
924+
chunks = [data[i * chunk_size:(i + 1) * chunk_size] for i in range(num_cores)]
925+
926+
with multiprocessing.Pool(processes=num_cores) as pool:
927+
avg_time = full_load_benchmark(fp_benchmark, data, iterations)
928+
return avg_time
929+
930+
def full_load_intermission(gflops=0):
931+
if "AMD" in brandName:
932+
cpuColour = colours.red()
933+
elif "Intel" in brandName:
934+
cpuColour = colours.cyan()
935+
else:
936+
cpuColour = colours.magenta()
937+
938+
print(f"Your {cpuColour}{colours.bold()}{brandName}{colours.reset()} has {colours.green()}completed{colours.reset()} the {colours.cyan()}GFLOPs Performance Test{colours.reset()} with a score of {colours.cyan()}{gflops} GFLOPs{colours.reset()}.")
939+
print("------")
940+
print(f"Next stage: {colours.red()}Full Load Test{colours.reset()}.")
941+
942+
for x in range(0,3):
943+
print(f"{3-x}", end="", flush=True)
944+
945+
if 3-x > 1:
946+
print(", ", end="", flush=True)
947+
else:
948+
print("...")
949+
950+
time.sleep(1)
951+
952+
print("------")
953+
print(f"Currently executing the {colours.red()}Full Load Test{colours.reset()}, this shouldn't take long...")
954+
955+
data = list(range(5_000_000))
956+
num_cores = multiprocessing.cpu_count()
957+
avg_time = run_full_load_benchmark(num_cores, data)
958+
959+
score = round((2 / avg_time) * 1000 / math.log(avg_time + math.e))
960+
961+
print(f"Your system scored {colours.red()}{score}{colours.reset()} points!")
962+
print("------")
963+
print(f"{colours.green()}Full Load Test complete!{colours.reset()}")
964+
time.sleep(3)
965+
966+
return score
967+
#Full Load Test SUBROUTINES END
968+
875969
def multiCore(showResults):
876970
def intense1(threadNo, coreID):
877971
p = psutil.Process(os.getpid())
@@ -975,7 +1069,8 @@ def run_processes():
9751069
gflops = calculateGFLOPS("2", coreCount)
9761070
time.sleep(3)
9771071
clear()
978-
1072+
full_load_score = full_load_intermission(gflops=gflops)
1073+
clear()
9791074

9801075
if not dynamicMode and not fullTest:
9811076
data = [["", score, "", ""]]
@@ -994,8 +1089,9 @@ def run_processes():
9941089
print(f"{colours.cyan()}Multi core score{colours.reset()}: {score} points")
9951090
print("---")
9961091
print(f"{colours.green()}Floating point operations performance{colours.reset()}: {round(gflops,2)} GFLOPs")
1092+
print(f"{colours.red()}Full Load Test score{colours.reset()}: {full_load_score} points")
9971093

998-
return score, gflops
1094+
return score, gflops, full_load_score
9991095

10001096

10011097
def multiThread(showResults):
@@ -1151,7 +1247,7 @@ def coolDown(points):
11511247

11521248
singleCoreScore = singleCore(False)
11531249
coolDown(singleCoreScore)
1154-
multiCoreScore, gflops = multiCore(False)
1250+
multiCoreScore, gflops, fullLoadScore = multiCore(False)
11551251
coolDown(multiCoreScore)
11561252
multiThreadScore = multiThread(False)
11571253

@@ -1261,7 +1357,7 @@ def avg(colName):
12611357

12621358
##Now we attempt to connect to the database
12631359
if not dynamicMode and apikey:
1264-
upload_and_return_status(brandName, systemCoreCount, Threads, memRaw, singleCoreScore, multiCoreScore, multiThreadScore, gflops, finalScore, distroName, version, apikey)
1360+
upload_and_return_status(brandName, systemCoreCount, Threads, memRaw, singleCoreScore, multiCoreScore, multiThreadScore, gflops, fullLoadScore, finalScore, distroName, version, apikey)
12651361

12661362
def test_speed():
12671363
try:

0 commit comments

Comments
 (0)