diff --git a/lib/cpu.js b/lib/cpu.js index 3a438e4..e334894 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -409,14 +409,17 @@ function getCpu() { cache: {} }; if (_darwin) { - exec('sysctl machdep.cpu hw.cpufrequency_max hw.cpufrequency_min hw.packages hw.physicalcpu_max hw.ncpu', function (error, stdout) { - // if (!error) { + exec('sysctl machdep.cpu hw.cpufrequency_max hw.cpufrequency_min hw.packages hw.physicalcpu_max hw.ncpu hw.tbfrequency', function (error, stdout) { let lines = stdout.toString().split('\n'); const modelline = util.getValue(lines, 'machdep.cpu.brand_string'); const modellineParts = modelline.split('@'); result.brand = modellineParts[0].trim(); result.speed = modellineParts[1] ? modellineParts[1].trim() : '0'; 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; result = cpuBrandManufacturer(result); 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 countCores = util.getValue(lines, 'hw.physicalcpu_max'); const countThreads = util.getValue(lines, 'hw.ncpu'); + if (os.arch === 'arm64') { + result.socket = 'SOC'; + } if (countProcessors) { result.processors = parseInt(countProcessors) || 1; } @@ -435,7 +441,6 @@ function getCpu() { result.cores = parseInt(countThreads) || util.cores(); result.physicalCores = parseInt(countCores) || util.cores(); } - // } cpuCache().then(res => { result.cache = res; resolve(result); @@ -719,7 +724,8 @@ function getCpuCurrentSpeedSync() { if (cpus[i].speed > maxFreq) maxFreq = 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; return { diff --git a/lib/filesystem.js b/lib/filesystem.js index 49c223a..edcc0e0 100755 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -41,7 +41,7 @@ function fsSize(callback) { let macOsDisks = []; function getmacOsFsType(fs) { - if (!fs.startsWith('/')) { return 'NFS' }; + if (!fs.startsWith('/')) { return 'NFS'; } const parts = fs.split('/'); const fsShort = parts[parts.length - 1]; const macOsDisksSingle = macOsDisks.filter(item => item.indexOf(fsShort) >= 0) @@ -1023,7 +1023,7 @@ function diskLayout(callback) { } if (_windows) { try { - util.wmic('diskdrive get /value').then((stdout, error) => { + util.wmic('diskdrive get /value').then((stdout) => { let devices = stdout.toString().split(/\n\s*\n/); devices.forEach(function (device) { let lines = device.split('\r\n');