diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6c7ffde..5a80678 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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()` |
diff --git a/docs/cpu.html b/docs/cpu.html
index 334e669..dfbc345 100644
--- a/docs/cpu.html
+++ b/docs/cpu.html
@@ -294,7 +294,7 @@
X |
X |
|
- L1D (data) size |
+ L1D (data) size bytes |
|
@@ -304,7 +304,7 @@
X |
X |
|
- L1I (instruction) size |
+ L1I (instruction) size bytes |
|
@@ -314,7 +314,7 @@
X |
X |
|
- L2 size |
+ L2 size bytes |
|
@@ -324,7 +324,7 @@
X |
X |
|
- L3 size |
+ L3 size bytes |
|
@@ -352,7 +352,7 @@ si.cpu().then(data => console.log(data));
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 }
}
diff --git a/docs/history.html b/docs/history.html
index 8f5a9b5..ea86569 100644
--- a/docs/history.html
+++ b/docs/history.html
@@ -56,6 +56,11 @@
+
+ | 5.7.14 |
+ 2021-08-01 |
+ cpu() cache calculation fix (linux) |
+
| 5.7.13 |
2021-07-28 |
diff --git a/docs/index.html b/docs/index.html
index d251b4f..f90fbe2 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -170,7 +170,7 @@
systeminformation
- New Version: 5.7.13
+ New Version: 5.7.14
@@ -211,7 +211,7 @@
Downloads last month
diff --git a/lib/cpu.js b/lib/cpu.js
index aef117f..f5c4aba 100644
--- a/lib/cpu.js
+++ b/lib/cpu.js
@@ -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));
}
});
}