cpu() cache calculation fix (linux)

This commit is contained in:
Sebastian Hildebrandt 2021-08-01 12:24:58 +02:00
parent 622208cb96
commit 7e811e52d5
5 changed files with 21 additions and 15 deletions

View File

@ -77,6 +77,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 5.7.14 | 2021-08-01 | `cpu()` cache calculation fix (linux) |
| 5.7.13 | 2021-07-28 | `osInfo()` fix uefi detection (win) |
| 5.7.12 | 2021-07-27 | `osInfo()` fix uefi detection (win) |
| 5.7.11 | 2021-07-27 | typescript typings fix `bluetoothDevices()` |

View File

@ -294,7 +294,7 @@
<td>X</td>
<td>X</td>
<td></td>
<td>L1D (data) size</td>
<td>L1D (data) size bytes</td>
</tr>
<tr>
<td></td>
@ -304,7 +304,7 @@
<td>X</td>
<td>X</td>
<td></td>
<td>L1I (instruction) size</td>
<td>L1I (instruction) size bytes</td>
</tr>
<tr>
<td></td>
@ -314,7 +314,7 @@
<td>X</td>
<td>X</td>
<td></td>
<td>L2 size</td>
<td>L2 size bytes</td>
</tr>
<tr>
<td></td>
@ -324,7 +324,7 @@
<td>X</td>
<td>X</td>
<td></td>
<td>L3 size</td>
<td>L3 size bytes</td>
</tr>
<tr class="example">
<td></td>
@ -352,7 +352,7 @@ si.cpu().then(data => console.log(data));</code></pre class="example">
socket: 'LGA1151',
flags: 'fpu vme de pse ...',
virtualization: true,
cache: { l1d: 262144, l1i: 262144, l2: 2, l3: 16 }
cache: { l1d: 262144, l1i: 262144, l2: 2097152, l3: 16777216 }
}</pre>
</tr>
<tr>

View File

@ -56,6 +56,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.7.14</th>
<td>2021-08-01</td>
<td><span class="code">cpu()</span> cache calculation fix (linux)</td>
</tr>
<tr>
<th scope="row">5.7.13</th>
<td>2021-07-28</td>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</div>
<div class="version">New Version: <span id="version">5.7.13</span></div>
<div class="version">New Version: <span id="version">5.7.14</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div>
<div class="down">
@ -211,7 +211,7 @@
<div class="title">Downloads last month</div>
</div>
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
<div class="numbers">448</div>
<div class="numbers">449</div>
<div class="title">Dependents</div>
</div>
</div>

View File

@ -636,13 +636,13 @@ function getCpu() {
result.stepping = util.getValue(lines, 'stepping');
result.revision = util.getValue(lines, 'cpu revision');
result.cache.l1d = util.getValue(lines, 'l1d cache');
if (result.cache.l1d) { result.cache.l1d = parseInt(result.cache.l1d) * (result.cache.l1d.indexOf('K') !== -1 ? 1024 : 1); }
if (result.cache.l1d) { result.cache.l1d = parseInt(result.cache.l1d) * (result.cache.l1d.indexOf('M') !== -1 ? 1024 * 1024 : (result.cache.l1d.indexOf('K') !== -1 ? 1024 : 1)); }
result.cache.l1i = util.getValue(lines, 'l1i cache');
if (result.cache.l1i) { result.cache.l1i = parseInt(result.cache.l1i) * (result.cache.l1i.indexOf('K') !== -1 ? 1024 : 1); }
if (result.cache.l1i) { result.cache.l1i = parseInt(result.cache.l1i) * (result.cache.l1i.indexOf('M') !== -1 ? 1024 * 1024 : (result.cache.l1i.indexOf('K') !== -1 ? 1024 : 1)); }
result.cache.l2 = util.getValue(lines, 'l2 cache');
if (result.cache.l2) { result.cache.l2 = parseInt(result.cache.l2) * (result.cache.l2.indexOf('K') !== -1 ? 1024 : 1); }
if (result.cache.l2) { result.cache.l2 = parseInt(result.cache.l2) * (result.cache.l2.indexOf('M') !== -1 ? 1024 * 1024 : (result.cache.l2.indexOf('K') !== -1 ? 1024 : 1)); }
result.cache.l3 = util.getValue(lines, 'l3 cache');
if (result.cache.l3) { result.cache.l3 = parseInt(result.cache.l3) * (result.cache.l3.indexOf('K') !== -1 ? 1024 : 1); }
if (result.cache.l3) { result.cache.l3 = parseInt(result.cache.l3) * (result.cache.l3.indexOf('M') !== -1 ? 1024 * 1024 : (result.cache.l3.indexOf('K') !== -1 ? 1024 : 1)); }
const threadsPerCore = util.getValue(lines, 'thread(s) per core') || '1';
// const coresPerSocketInt = parseInt(util.getValue(lines, 'cores(s) per socket') || '1', 10);
@ -1285,16 +1285,16 @@ function cpuCache(callback) {
lines.forEach(function (line) {
let parts = line.split(':');
if (parts[0].toUpperCase().indexOf('L1D CACHE') !== -1) {
result.l1d = parseInt(parts[1].trim()) * (parts[1].indexOf('K') !== -1 ? 1024 : 1);
result.l1d = parseInt(parts[1].trim()) * (parts[1].indexOf('M') !== -1 ? 1024 * 1024 : (parts[1].indexOf('K') !== -1 ? 1024 : 1));
}
if (parts[0].toUpperCase().indexOf('L1I CACHE') !== -1) {
result.l1i = parseInt(parts[1].trim()) * (parts[1].indexOf('K') !== -1 ? 1024 : 1);
result.l1i = parseInt(parts[1].trim()) * (parts[1].indexOf('M') !== -1 ? 1024 * 1024 : (parts[1].indexOf('K') !== -1 ? 1024 : 1));
}
if (parts[0].toUpperCase().indexOf('L2 CACHE') !== -1) {
result.l2 = parseInt(parts[1].trim()) * (parts[1].indexOf('K') !== -1 ? 1024 : 1);
result.l2 = parseInt(parts[1].trim()) * (parts[1].indexOf('M') !== -1 ? 1024 * 1024 : (parts[1].indexOf('K') !== -1 ? 1024 : 1));
}
if (parts[0].toUpperCase().indexOf('L3 CACHE') !== -1) {
result.l3 = parseInt(parts[1].trim()) * (parts[1].indexOf('K') !== -1 ? 1024 : 1);
result.l3 = parseInt(parts[1].trim()) * (parts[1].indexOf('M') !== -1 ? 1024 * 1024 : (parts[1].indexOf('K') !== -1 ? 1024 : 1));
}
});
}