cpu() fixed parsing (mac OS)

This commit is contained in:
Sebastian Hildebrandt
2023-06-26 13:06:08 +02:00
parent 73da2aef32
commit c1545b2f22
4 changed files with 17 additions and 7 deletions
+9 -5
View File
@@ -642,12 +642,16 @@ function getCpu() {
const countCores = util.getValue(lines, 'hw.physicalcpu_max');
const countThreads = util.getValue(lines, 'hw.ncpu');
if (os.arch() === 'arm64') {
const clusters = execSync('ioreg -c IOPlatformDevice -d 3 -r | grep cluster-type').toString().split('\n');
const efficiencyCores = clusters.filter(line => line.indexOf('"E"') >= 0).length;
const performanceCores = clusters.filter(line => line.indexOf('"P"') >= 0).length;
result.socket = 'SOC';
result.efficiencyCores = efficiencyCores;
result.performanceCores = performanceCores;
try {
const clusters = execSync('ioreg -c IOPlatformDevice -d 3 -r | grep cluster-type').toString().split('\n');
const efficiencyCores = clusters.filter(line => line.indexOf('"E"') >= 0).length;
const performanceCores = clusters.filter(line => line.indexOf('"P"') >= 0).length;
result.efficiencyCores = efficiencyCores;
result.performanceCores = performanceCores;
} catch (e) {
util.noop();
}
}
if (countProcessors) {
result.processors = parseInt(countProcessors) || 1;