@@ -174,10 +174,6 @@ func (ko *LkkOS) GetCpuInfo() *CpuInfo {
174
174
Threads : 0 ,
175
175
}
176
176
177
- //打印CPU信息
178
- _ , cpuInfos , _ := ko .System ("sysctl machdep.cpu" )
179
- println ("cpuInfos: " , cpuInfos )
180
-
181
177
//调用系统命令获取,例如
182
178
//$ sysctl machdep.cpu
183
179
//machdep.cpu.cores_per_package: 10
@@ -189,25 +185,18 @@ func (ko *LkkOS) GetCpuInfo() *CpuInfo {
189
185
//machdep.cpu.feature_bits: 151121000215084031
190
186
//machdep.cpu.family: 6
191
187
188
+ //打印CPU信息
189
+ //cpuInfos, _ := unix.Sysctl("machdep.cpu")
190
+ //println("cpuInfos: ", cpuInfos)
191
+
192
192
res .Model , _ = unix .Sysctl ("machdep.cpu.brand_string" )
193
- res .Vendor , _ = unix .Sysctl ("machdep.cpu.vendor" )
193
+ res .Vendor , _ = unix .Sysctl ("machdep.cpu.vendor" ) //有可能为空
194
194
195
- cacheSize , _ := unix .SysctlUint32 ("machdep.cpu.cache.size" )
195
+ cacheSize , _ := unix .SysctlUint32 ("machdep.cpu.cache.size" ) //有可能为空
196
196
cpus , _ := unix .SysctlUint32 ("hw.physicalcpu" )
197
197
cores , _ := unix .SysctlUint32 ("machdep.cpu.core_count" )
198
198
threads , _ := unix .SysctlUint32 ("machdep.cpu.thread_count" )
199
199
200
- if cpus == 0 {
201
- infos := ko .getIOInfos ()
202
- if len (infos ) > 0 {
203
- infoStr := string (infos )
204
- tmpStr := trim (KStr .GetEquationValue (infoStr , "AppleARMCPU" ), "<" , ">" , `"` , `'` )
205
- if tmpStr != "" {
206
- cpus = uint32 (KConv .ToInt (tmpStr ))
207
- }
208
- }
209
- }
210
-
211
200
res .Cache = uint (cacheSize )
212
201
res .Cpus = uint (cpus )
213
202
res .Cores = uint (cores )
0 commit comments