From 2816a48a66bf1bf3317722a528c64c41fb4b0270 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Wed, 27 May 2020 20:03:02 +0200 Subject: [PATCH] cpuTemperature() optimizes scanning AMD linux sensors --- CHANGELOG.md | 1 + README.md | 2 +- docs/history.html | 5 +++++ docs/index.html | 4 ++-- lib/cpu.js | 9 +++++++++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98d36a7..053d9c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.26.5 | 2020-05-27 | `cpuTemperature()` optimizes scanning AMD linux sensors | | 4.26.4 | 2020-05-21 | `cpuTemperature()` fix (BSD), code cleanup | | 4.26.3 | 2020-05-20 | updated documentation (macOS temperature) | | 4.26.2 | 2020-05-19 | `processes()` memory leak fix | diff --git a/README.md b/README.md index 2b0d794..d63f27f 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ [![Sponsoring][sponsor-badge]][sponsor-url] [![MIT license][license-img]][license-url] -This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 300 versions published, > 1 mio downloads per month, > 9 mio downloads overall. Thank you to all who contributed to this project! +This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 300 versions published, > 1 mio downloads per month, > 10 mio downloads overall. Thank you to all who contributed to this project! ## New Version 4.0 diff --git a/docs/history.html b/docs/history.html index 311e4e4..f4319d6 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.26.5 + 2020-05-27 + cpuTemperature() optimizes scanning AMD linux sensors + 4.26.4 2020-05-21 diff --git a/docs/index.html b/docs/index.html index 0709872..7d86243 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.26.4
+
Current Version: 4.26.5
@@ -207,7 +207,7 @@
Downloads last month
-
271
+
275
Dependends
diff --git a/lib/cpu.js b/lib/cpu.js index 1dd4740..e55ca98 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -789,6 +789,7 @@ function cpuTemperature(callback) { exec('sensors', function (error, stdout) { if (!error) { let lines = stdout.toString().split('\n'); + let tdieTemp = -1; lines.forEach(function (line) { let regex = /[+-]([^°]*)/g; let temps = line.match(regex); @@ -799,6 +800,9 @@ function cpuTemperature(callback) { if (firstPart.indexOf('CORE ') !== -1) { result.cores.push(parseFloat(temps)); } + if (firstPart.indexOf('TDIE') !== -1 && tdieTemp === -1) { + tdieTemp = parseFloat(temps); + } }); if (result.cores.length > 0) { if (result.main === -1) { @@ -806,6 +810,11 @@ function cpuTemperature(callback) { } let maxtmp = Math.max.apply(Math, result.cores); result.max = (maxtmp > result.main) ? maxtmp : result.main; + } else { + if (result.main === -1 && tdieTemp !== -1) { + result.main = tdieTemp; + result.max = tdieTemp; + } } if (callback) { callback(result); } resolve(result);