cpu() Apple Silicon M1 adaptions
This commit is contained in:
parent
0da06759cb
commit
e840ed91b4
14
lib/cpu.js
14
lib/cpu.js
@ -409,14 +409,17 @@ function getCpu() {
|
|||||||
cache: {}
|
cache: {}
|
||||||
};
|
};
|
||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
exec('sysctl machdep.cpu hw.cpufrequency_max hw.cpufrequency_min hw.packages hw.physicalcpu_max hw.ncpu', function (error, stdout) {
|
exec('sysctl machdep.cpu hw.cpufrequency_max hw.cpufrequency_min hw.packages hw.physicalcpu_max hw.ncpu hw.tbfrequency', function (error, stdout) {
|
||||||
// if (!error) {
|
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
const modelline = util.getValue(lines, 'machdep.cpu.brand_string');
|
const modelline = util.getValue(lines, 'machdep.cpu.brand_string');
|
||||||
const modellineParts = modelline.split('@');
|
const modellineParts = modelline.split('@');
|
||||||
result.brand = modellineParts[0].trim();
|
result.brand = modellineParts[0].trim();
|
||||||
result.speed = modellineParts[1] ? modellineParts[1].trim() : '0';
|
result.speed = modellineParts[1] ? modellineParts[1].trim() : '0';
|
||||||
result.speed = parseFloat(result.speed.replace(/GHz+/g, '')).toFixed(2);
|
result.speed = parseFloat(result.speed.replace(/GHz+/g, '')).toFixed(2);
|
||||||
|
let tbFrequency = util.getValue(lines, 'hw.tbfrequency') / 1000000000.0;
|
||||||
|
tbFrequency = tbFrequency < 1 ? tbFrequency * 1000 : tbFrequency;
|
||||||
|
result.speed = result.speed === '0.00' ? tbFrequency.toFixed(2) : result.speed;
|
||||||
|
|
||||||
_cpu_speed = result.speed;
|
_cpu_speed = result.speed;
|
||||||
result = cpuBrandManufacturer(result);
|
result = cpuBrandManufacturer(result);
|
||||||
result.speedmin = (util.getValue(lines, 'hw.cpufrequency_min') / 1000000000.0).toFixed(2);
|
result.speedmin = (util.getValue(lines, 'hw.cpufrequency_min') / 1000000000.0).toFixed(2);
|
||||||
@ -428,6 +431,9 @@ function getCpu() {
|
|||||||
const countProcessors = util.getValue(lines, 'hw.packages');
|
const countProcessors = util.getValue(lines, 'hw.packages');
|
||||||
const countCores = util.getValue(lines, 'hw.physicalcpu_max');
|
const countCores = util.getValue(lines, 'hw.physicalcpu_max');
|
||||||
const countThreads = util.getValue(lines, 'hw.ncpu');
|
const countThreads = util.getValue(lines, 'hw.ncpu');
|
||||||
|
if (os.arch === 'arm64') {
|
||||||
|
result.socket = 'SOC';
|
||||||
|
}
|
||||||
if (countProcessors) {
|
if (countProcessors) {
|
||||||
result.processors = parseInt(countProcessors) || 1;
|
result.processors = parseInt(countProcessors) || 1;
|
||||||
}
|
}
|
||||||
@ -435,7 +441,6 @@ function getCpu() {
|
|||||||
result.cores = parseInt(countThreads) || util.cores();
|
result.cores = parseInt(countThreads) || util.cores();
|
||||||
result.physicalCores = parseInt(countCores) || util.cores();
|
result.physicalCores = parseInt(countCores) || util.cores();
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
cpuCache().then(res => {
|
cpuCache().then(res => {
|
||||||
result.cache = res;
|
result.cache = res;
|
||||||
resolve(result);
|
resolve(result);
|
||||||
@ -719,7 +724,8 @@ function getCpuCurrentSpeedSync() {
|
|||||||
if (cpus[i].speed > maxFreq) maxFreq = cpus[i].speed;
|
if (cpus[i].speed > maxFreq) maxFreq = cpus[i].speed;
|
||||||
if (cpus[i].speed < minFreq) minFreq = cpus[i].speed;
|
if (cpus[i].speed < minFreq) minFreq = cpus[i].speed;
|
||||||
}
|
}
|
||||||
cores.push(parseFloat(((cpus[i].speed + 1) / 1000).toFixed(2)));
|
const freq = (cpus[i].speed + 1) / 1000;
|
||||||
|
cores.push(parseFloat((freq < 0.1 ? freq * 1000 : freq).toFixed(2)));
|
||||||
}
|
}
|
||||||
avgFreq = avgFreq / cpus.length;
|
avgFreq = avgFreq / cpus.length;
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -41,7 +41,7 @@ function fsSize(callback) {
|
|||||||
let macOsDisks = [];
|
let macOsDisks = [];
|
||||||
|
|
||||||
function getmacOsFsType(fs) {
|
function getmacOsFsType(fs) {
|
||||||
if (!fs.startsWith('/')) { return 'NFS' };
|
if (!fs.startsWith('/')) { return 'NFS'; }
|
||||||
const parts = fs.split('/');
|
const parts = fs.split('/');
|
||||||
const fsShort = parts[parts.length - 1];
|
const fsShort = parts[parts.length - 1];
|
||||||
const macOsDisksSingle = macOsDisks.filter(item => item.indexOf(fsShort) >= 0)
|
const macOsDisksSingle = macOsDisks.filter(item => item.indexOf(fsShort) >= 0)
|
||||||
@ -1023,7 +1023,7 @@ function diskLayout(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
try {
|
try {
|
||||||
util.wmic('diskdrive get /value').then((stdout, error) => {
|
util.wmic('diskdrive get /value').then((stdout) => {
|
||||||
let devices = stdout.toString().split(/\n\s*\n/);
|
let devices = stdout.toString().split(/\n\s*\n/);
|
||||||
devices.forEach(function (device) {
|
devices.forEach(function (device) {
|
||||||
let lines = device.split('\r\n');
|
let lines = device.split('\r\n');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user