cpuTemperature() optimizes scanning AMD linux sensors

This commit is contained in:
Sebastian Hildebrandt 2020-05-27 20:03:02 +02:00
parent 66864ec8ff
commit 2816a48a66
5 changed files with 18 additions and 3 deletions

View File

@ -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 |

View File

@ -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

View File

@ -83,6 +83,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.26.5</th>
<td>2020-05-27</td>
<td><span class="code">cpuTemperature()</span> optimizes scanning AMD linux sensors</td>
</tr>
<tr>
<th scope="row">4.26.4</th>
<td>2020-05-21</td>

View File

@ -168,7 +168,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.26.4</span></div>
<div class="version">Current Version: <span id="version">4.26.5</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">
@ -207,7 +207,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">271</div>
<div class="numbers">275</div>
<div class="title">Dependends</div>
</div>
</div>

View File

@ -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);