File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -69,20 +69,16 @@ def get_cpu_info() -> dict[str, float | int]:
6969 """获取 CPU 信息"""
7070 cpu_info = {'usage' : round (psutil .cpu_percent (percpu = False ), 2 )} # %
7171
72- # 检查是否是 Apple M系列芯片
73- if platform .system () == 'Darwin' and 'arm' in platform .machine ().lower ():
72+ try :
73+ # CPU 频率信息,最大、最小和当前频率
74+ cpu_freq = psutil .cpu_freq ()
75+ cpu_info .update ({
76+ 'max_freq' : round (cpu_freq .max , 2 ), # MHz
77+ 'min_freq' : round (cpu_freq .min , 2 ), # MHz
78+ 'current_freq' : round (cpu_freq .current , 2 ), # MHz
79+ })
80+ except Exception :
7481 cpu_info .update ({'max_freq' : 0 , 'min_freq' : 0 , 'current_freq' : 0 })
75- else :
76- try :
77- # CPU 频率信息,最大、最小和当前频率
78- cpu_freq = psutil .cpu_freq ()
79- cpu_info .update ({
80- 'max_freq' : round (cpu_freq .max , 2 ), # MHz
81- 'min_freq' : round (cpu_freq .min , 2 ), # MHz
82- 'current_freq' : round (cpu_freq .current , 2 ), # MHz
83- })
84- except (FileNotFoundError , AttributeError ):
85- cpu_info .update ({'max_freq' : 0 , 'min_freq' : 0 , 'current_freq' : 0 })
8682
8783 # CPU 逻辑核心数,物理核心数
8884 cpu_info .update ({
You can’t perform that action at this time.
0 commit comments