cpu() Apple Silicon M1 cores

This commit is contained in:
Sebastian Hildebrandt 2020-12-17 20:53:51 +01:00
parent e840ed91b4
commit a465449fa4
4 changed files with 30 additions and 0 deletions

View File

@ -175,6 +175,8 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (m
| | governor | X | | | | | e.g. 'powersave' | | | governor | X | | | | | e.g. 'powersave' |
| | cores | X | X | X | X | | # cores | | | cores | X | X | X | X | | # cores |
| | physicalCores | X | X | X | X | | # physical cores | | | physicalCores | X | X | X | X | | # physical cores |
| | efficiencyCores | | | X | | | # efficiancy cores (ARM only) |
| | performanceCores | | | X | | | # performance cores (ARM only) |
| | processors | X | X | X | X | | # processors | | | processors | X | X | X | X | | # processors |
| | socket | X | X | | X | | socket type e.g. "LGA1356" | | | socket | X | X | | X | | socket type e.g. "LGA1356" |
| | vendor | X | X | X | X | | vendor ID | | | vendor | X | X | X | X | | vendor ID |

View File

@ -155,6 +155,26 @@
<td></td> <td></td>
<td># physical cores</td> <td># physical cores</td>
</tr> </tr>
<tr>
<td></td>
<td>efficiencyCores</td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td># efficiency cores (ARM only)</td>
</tr>
<tr>
<td></td>
<td>performanceCores</td>
<td></td>
<td></td>
<td>X</td>
<td></td>
<td></td>
<td># performance cores (ARM only)</td>
</tr>
<tr> <tr>
<td></td> <td></td>
<td>processors</td> <td>processors</td>

View File

@ -15,6 +15,7 @@
const os = require('os'); const os = require('os');
const exec = require('child_process').exec; const exec = require('child_process').exec;
const execSync = require('child_process').execSync;
const fs = require('fs'); const fs = require('fs');
const util = require('./util'); const util = require('./util');
@ -432,7 +433,12 @@ function getCpu() {
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') { 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.socket = 'SOC';
result.efficiencyCores = efficiencyCores;
result.performanceCores = performanceCores;
} }
if (countProcessors) { if (countProcessors) {
result.processors = parseInt(countProcessors) || 1; result.processors = parseInt(countProcessors) || 1;

2
lib/index.d.ts vendored
View File

@ -73,6 +73,8 @@ export namespace Systeminformation {
governor: string; governor: string;
cores: number; cores: number;
physicalCores: number; physicalCores: number;
efficiencyCores?: number;
performanceCores?: number;
processors: number; processors: number;
socket: string; socket: string;
cache: CpuCacheData; cache: CpuCacheData;