cpu() Apple Silicon M1 mem

This commit is contained in:
Sebastian Hildebrandt 2020-12-17 23:01:26 +01:00
parent 57d23559ed
commit 6c222d4dcc
2 changed files with 25 additions and 4 deletions

View File

@ -410,7 +410,7 @@ function getCpu() {
cache: {}
};
if (_darwin) {
exec('sysctl machdep.cpu hw.cpufrequency_max hw.cpufrequency_min hw.packages hw.physicalcpu_max hw.ncpu hw.tbfrequency', function (error, stdout) {
exec('sysctl machdep.cpu hw.cpufrequency_max hw.cpufrequency_min hw.packages hw.physicalcpu_max hw.ncpu hw.tbfrequency hw.cpufamily hw.cpusubfamily', function (error, stdout) {
let lines = stdout.toString().split('\n');
const modelline = util.getValue(lines, 'machdep.cpu.brand_string');
const modellineParts = modelline.split('@');
@ -425,10 +425,10 @@ function getCpu() {
result = cpuBrandManufacturer(result);
result.speedmin = util.getValue(lines, 'hw.cpufrequency_min') ? (util.getValue(lines, 'hw.cpufrequency_min') / 1000000000.0).toFixed(2) : result.speed;
result.speedmax = util.getValue(lines, 'hw.cpufrequency_max') ? (util.getValue(lines, 'hw.cpufrequency_max') / 1000000000.0).toFixed(2) : result.speed;
result.vendor = util.getValue(lines, 'machdep.cpu.vendor');
result.family = util.getValue(lines, 'machdep.cpu.family');
result.vendor = util.getValue(lines, 'machdep.cpu.vendor') || 'Apple';
result.family = util.getValue(lines, 'machdep.cpu.family') || util.getValue(lines, 'hw.cpufamily');
result.model = util.getValue(lines, 'machdep.cpu.model');
result.stepping = util.getValue(lines, 'machdep.cpu.stepping');
result.stepping = util.getValue(lines, 'machdep.cpu.stepping') || util.getValue(lines, 'hw.cpusubfamily');
const countProcessors = util.getValue(lines, 'hw.packages');
const countCores = util.getValue(lines, 'hw.physicalcpu_max');
const countThreads = util.getValue(lines, 'hw.ncpu');

View File

@ -422,6 +422,27 @@ function memLayout(callback) {
}
});
}
if (!result.length) {
const lines = stdout.toString().split('\n');
const size = parseInt(util.getValue(lines, ' Memory:'));
const type = parseInt(util.getValue(lines, ' Type:'),);
if (size && type) {
result.push({
size,
bank: 0,
type,
clockSpeed: 0,
formFactor: '',
manufacturer: '',
partNum: '',
serialNum: '',
voltageConfigured: -1,
voltageMin: -1,
voltageMax: -1,
});
}
}
if (callback) { callback(result); }
resolve(result);
});