getCpuCurrentSpeedSync() workarround fix

This commit is contained in:
Sebastian Hildebrandt 2020-04-26 16:14:55 +02:00
parent 4c28e0ac8e
commit 772e3b02cd
4 changed files with 27 additions and 15 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.23.7 | 2020-04-26 | `getCpuCurrentSpeedSync()` workarround fix |
| 4.23.6 | 2020-04-25 | `networkGatewayDefault()` bug fix no interfaces |
| 4.23.5 | 2020-04-20 | updated docs |
| 4.23.4 | 2020-04-20 | `users()` optimized parseDateTime function |

View File

@ -84,8 +84,13 @@
</thead>
<tbody>
<tr>
<th scope="row">4.23.4</th>
<td>2020-04-20</td>
<th scope="row">4.23.7</th>
<td>2020-04-2&</td>
<td><span class="code">getCpuCurrentSpeedSync()</span> workarround fix</td>
</tr>
<tr>
<th scope="row">4.23.6</th>
<td>2020-04-25</td>
<td><span class="code">networkGatewayDefault()</span> bugfix no interfaces</td>
</tr>
<tr>

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.23.6</span></div>
<div class="version">Current Version: <span id="version">4.23.7</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">

View File

@ -695,7 +695,7 @@ function getCpuCurrentSpeedSync() {
let avgFreq = 0;
let cores = [];
if (cpus.length) {
if (cpus && cpus.length) {
for (let i in cpus) {
if ({}.hasOwnProperty.call(cpus, i)) {
avgFreq = avgFreq + cpus[i].speed;
@ -1142,7 +1142,7 @@ function getLoad() {
let totalIrq = 0;
let totalIdle = 0;
let cores = [];
_corecount = cpus.length;
_corecount = (cpus && cpus.length) ? cpus.length : 1;
for (let i = 0; i < _corecount; i++) {
const cpu = cpus[i].times;
@ -1292,17 +1292,23 @@ function getFullLoad() {
let totalIrq = 0;
let totalIdle = 0;
for (let i = 0, len = cpus.length; i < len; i++) {
const cpu = cpus[i].times;
totalUser += cpu.user;
totalSystem += cpu.sys;
totalNice += cpu.nice;
totalIrq += cpu.irq;
totalIdle += cpu.idle;
}
let totalTicks = totalIdle + totalIrq + totalNice + totalSystem + totalUser;
let result = (totalTicks - totalIdle) / totalTicks * 100.0;
let result = 0;
if (cpus && cpus.length) {
for (let i = 0, len = cpus.length; i < len; i++) {
const cpu = cpus[i].times;
totalUser += cpu.user;
totalSystem += cpu.sys;
totalNice += cpu.nice;
totalIrq += cpu.irq;
totalIdle += cpu.idle;
}
let totalTicks = totalIdle + totalIrq + totalNice + totalSystem + totalUser;
result = (totalTicks - totalIdle) / totalTicks * 100.0;
} else {
result = 0;
}
resolve(result);
});
});