-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxmrig_ram_search.py
70 lines (58 loc) · 2.29 KB
/
xmrig_ram_search.py
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
import tqdm
import time
import requests
import urllib.parse
CPU = "AMD Ryzen 9 5950X 16-Core Processor"
TARGET_RAM = "F4-4000C18D-32GVK"
URL = "https://api.xmrig.com/1/benchmark"
def fetch_benchmarks():
"""
Fetches the benchmark data from the API and returns the JSON response.
"""
response = requests.get(URL + 's?cpu=' + urllib.parse.quote_plus(CPU))
return response.json()
def get_ram_info(benchmarks):
"""
Fetches the benchmark data for the specified RAM model from the xmrig.com API.
Args:
benchmarks (list): A list of dictionaries containing benchmark data.
Returns:
list: A list of dictionaries containing benchmark data with RAM information.
"""
ram_info_list = []
benchmarks=benchmarks[1950:2050] #limit the search
for benchmark in tqdm.tqdm(benchmarks, desc="Processing benchmarks", unit="benchmark"):
time.sleep(2)
benchmark_id = benchmark.get("id")
if benchmark_id:
uri = URL + '/' + benchmark_id
response = requests.get(uri)
if response.status_code == 200:
benchmark_data = response.json()
# print(benchmark_data)
if benchmark_data["dmi"] == None:
print(f'Error requesting benchmark ID: {benchmark_data['id']}')
continue
for dimm in benchmark_data["dmi"]["memory"]:
if dimm.get("product") == TARGET_RAM:
ram_info_list.append(benchmark_data)
break
return ram_info_list
def get_top_benchmarks(filtered_benchmarks):
"""
Sorts the filtered benchmarks by performance and returns the top 5 results.
"""
sorted_benchmarks = sorted(filtered_benchmarks, key=lambda x: x["performance"], reverse=True)
return sorted_benchmarks[:5]
def main():
benchmarks = fetch_benchmarks()
filtered_benchmarks = get_ram_info(benchmarks)
input(filtered_benchmarks)
top_benchmarks = get_top_benchmarks(filtered_benchmarks)
for benchmark in top_benchmarks:
print(f"Performance: {benchmark['performance']}")
print(f"RAM Model: {benchmark['ram_model']}")
print(f"Timings: {benchmark['ram_timings']}")
print("---")
if __name__ == "__main__":
main()