From 7ca1d056c3d4bba74e6e38cf7e1aebe65ca6b01e Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 14 Nov 2021 19:57:36 +0100 Subject: [PATCH] time() timezone name, l1 cache improvements --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ docs/index.html | 2 +- lib/cpu.js | 30 ++++++++++++++++++++---------- lib/osinfo.js | 3 +-- package.json | 2 +- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e692c36..397c638 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 5.9.13 | 2021-11-14 | `time()` timezone name, `l1 cache` improvements | | 5.9.12 | 2021-11-13 | `users()` fix data check (windows) | | 5.9.11 | 2021-11-12 | `fsStats()` fix null result (bsd) | | 5.9.10 | 2021-11-11 | `powerShell` transition from `wmic` (windows) | diff --git a/docs/history.html b/docs/history.html index 4c20b8b..055043c 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,6 +57,11 @@ + + 5.9.13 + 2021-11-14 + time() timezone name, cpu() l1 cache improvement + 5.9.12 2021-11-13 diff --git a/docs/index.html b/docs/index.html index 692ffff..3b9ac8b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.9.12
+
New Version: 5.9.13
diff --git a/lib/cpu.js b/lib/cpu.js index df56bb2..1fe4160 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -781,7 +781,7 @@ function getCpu() { try { const workload = []; workload.push(util.powerShell('Get-WmiObject Win32_processor | fl *')); - workload.push(util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Purpose | fl *')); + workload.push(util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Level | fl *')); // workload.push(util.powerShell('Get-ComputerInfo -property "HyperV*"')); workload.push(util.powerShell('(Get-CimInstance Win32_ComputerSystem).HypervisorPresent')); @@ -852,16 +852,21 @@ function getCpu() { parts.forEach(function (part) { lines = part.split('\r\n'); const cacheType = util.getValue(lines, 'CacheType'); - const purpose = util.getValue(lines, 'Purpose'); + const level = util.getValue(lines, 'Level'); const installedSize = util.getValue(lines, 'InstalledSize'); // L1 Instructions - if (purpose === 'L1 Cache' && cacheType === '3') { + if (level === '3' && cacheType === '3') { result.cache.l1i = parseInt(installedSize, 10); } // L1 Data - if (purpose === 'L1 Cache' && cacheType === '4') { + if (level === '3' && cacheType === '4') { result.cache.l1d = parseInt(installedSize, 10); } + // L1 all + if (level === '3' && cacheType === '5' && !result.cache.l1i && !result.cache.l1d) { + result.cache.l1i = parseInt(installedSize, 10) / 2; + result.cache.l1d = parseInt(installedSize, 10) / 2; + } }); // lines = data[2].split('\r\n'); // result.virtualization = (util.getValue(lines, 'HyperVRequirementVirtualizationFirmwareEnabled').toLowerCase() === 'true'); @@ -1413,21 +1418,26 @@ function cpuCache(callback) { if (result.l2) { result.l2 = parseInt(result.l2, 10) * 1024; } if (result.l3) { result.l3 = parseInt(result.l3, 10) * 1024; } } - util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Purpose | fl ').then((stdout, error) => { + util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Level | fl ').then((stdout, error) => { if (!error) { const parts = stdout.split(/\n\s*\n/); parts.forEach(function (part) { const lines = part.split('\r\n'); const cacheType = util.getValue(lines, 'CacheType'); - const purpose = util.getValue(lines, 'Purpose'); + const level = util.getValue(lines, 'Level'); const installedSize = util.getValue(lines, 'InstalledSize'); // L1 Instructions - if (purpose === 'L1 Cache' && cacheType === '3') { - result.l1i = parseInt(installedSize, 10); + if (level === '3' && cacheType === '3') { + result.cache.l1i = parseInt(installedSize, 10); } // L1 Data - if (purpose === 'L1 Cache' && cacheType === '4') { - result.l1d = parseInt(installedSize, 10); + if (level === '3' && cacheType === '4') { + result.cache.l1d = parseInt(installedSize, 10); + } + // L1 all + if (level === '3' && cacheType === '5' && !result.cache.l1i && !result.cache.l1d) { + result.cache.l1i = parseInt(installedSize, 10) / 2; + result.cache.l1d = parseInt(installedSize, 10) / 2; } }); } diff --git a/lib/osinfo.js b/lib/osinfo.js index 41e3d8b..b144b02 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -35,12 +35,11 @@ const _sunos = (_platform === 'sunos'); function time() { let t = new Date().toString().split(' '); - return { current: Date.now(), uptime: os.uptime(), timezone: (t.length >= 7) ? t[5] : '', - timezoneName: (t.length >= 7) ? t.slice(6).join(' ').replace(/\(/g, '').replace(/\)/g, '') : '' + timezoneName: Intl ? Intl.DateTimeFormat().resolvedOptions().timeZone : (t.length >= 7) ? t.slice(6).join(' ').replace(/\(/g, '').replace(/\)/g, '') : '' }; } diff --git a/package.json b/package.json index 5d676b6..d8bfce1 100644 --- a/package.json +++ b/package.json @@ -93,6 +93,6 @@ "sunos" ], "engines": { - "node": ">=4.0.0" + "node": ">=8.0.0" } }