Skip to content

Commit

Permalink
fix cpu calculate
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed Jul 9, 2024
1 parent 6146f00 commit d8d51a4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/service/backends/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ def list_cpu():
ret.append("cpu"+str(i))
return ret

@cached
def get_num_of_cpu():
i = 0
while os.path.exists("/sys/devices/system/cpu/cpu"+str(i)):
i += 1
return i

@cached
def list_little_cpu():
max_all = 0
ret = []
for i in range(0, get_num_of_cpu()):
with open("/sys/devices/system/cpu/cpu{}//cpufreq/scaling_max_freq".format(i), "r") as f:
change_cpu_status(i,True)
with open("/sys/devices/system/cpu/cpu{}/cpufreq/scaling_max_freq".format(i), "r") as f:
freq = int(f.read())
if freq > max_all:
max_all = freq
Expand All @@ -27,6 +30,7 @@ def list_little_cpu():
ret.append("cpu"+str(i))
return ret

@cached
def list_big_cpu():
all_cpu = list_cpu()
for cpu in list_little_cpu():
Expand Down

0 comments on commit d8d51a4

Please sign in to comment.