cpu() fix, code cleanup

This commit is contained in:
Sebastian Hildebrandt 2019-02-08 18:05:56 +01:00
parent 459eb99a7f
commit 6790fb531e
4 changed files with 20 additions and 7 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment | | Version | Date | Comment |
| -------------- | -------------- | -------- | | -------------- | -------------- | -------- |
| 4.0.9 | 2019-02-08 | `cpu()` fix, code cleanup |
| 4.0.8 | 2019-02-05 | `inetLatency()` Windows fix parse chinese output | | 4.0.8 | 2019-02-05 | `inetLatency()` Windows fix parse chinese output |
| 4.0.7 | 2019-02-05 | `inetLatency()` Windows fix | | 4.0.7 | 2019-02-05 | `inetLatency()` Windows fix |
| 4.0.6 | 2019-02-04 | powershell catch error | | 4.0.6 | 2019-02-04 | powershell catch error |

View File

@ -80,6 +80,11 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<th scope="row">4.0.9</th>
<td>2019-02-08</td>
<td><span class="code">cpu()</span> fix, code clean up</td>
</tr>
<tr> <tr>
<th scope="row">4.0.8</th> <th scope="row">4.0.8</th>
<td>2019-02-05</td> <td>2019-02-05</td>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png"> <img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div> <div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div> <div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.0.7</span></div> <div class="version">Current Version: <span id="version">4.0.9</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> <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>
<div class="down"> <div class="down">
@ -193,7 +193,7 @@
</div> </div>
<div class="row number-section"> <div class="row number-section">
<div class="col-xl-4 col-lg-4 col-md-4 col-12"> <div class="col-xl-4 col-lg-4 col-md-4 col-12">
<div class="numbers">7,973</div> <div class="numbers">8,137</div>
<div class="title">Lines of code</div> <div class="title">Lines of code</div>
</div> </div>
<div class="col-xl-4 col-lg-4 col-md-4 col-12"> <div class="col-xl-4 col-lg-4 col-md-4 col-12">
@ -201,7 +201,7 @@
<div class="title">Downloads last month</div> <div class="title">Downloads last month</div>
</div> </div>
<div class="col-xl-4 col-lg-4 col-md-4 col-12"> <div class="col-xl-4 col-lg-4 col-md-4 col-12">
<div class="numbers">124</div> <div class="numbers">127</div>
<div class="title">Dependends</div> <div class="title">Dependends</div>
</div> </div>
</div> </div>

View File

@ -293,7 +293,7 @@ function getCpu() {
} }
if (result.speed === '0.00') { if (result.speed === '0.00') {
let current = getCpuCurrentSpeedSync(); let current = getCpuCurrentSpeedSync();
if (current !== '0.00') result.speed = current.avg.toFixed(2); if (current.avg !== 0) result.speed = current.avg.toFixed(2);
} }
_cpu_speed = result.speed; _cpu_speed = result.speed;
result.speedmin = Math.round(parseFloat(util.getValue(lines, 'cpu min mhz').replace(/,/g, '.')) / 10.0) / 100; result.speedmin = Math.round(parseFloat(util.getValue(lines, 'cpu min mhz').replace(/,/g, '.')) / 10.0) / 100;
@ -374,7 +374,7 @@ function getCpu() {
} }
if (result.speed === '0.00') { if (result.speed === '0.00') {
let current = getCpuCurrentSpeedSync(); let current = getCpuCurrentSpeedSync();
if (current !== '0.00') result.speed = current.avg.toFixed(2); if (current.avg !== 0) result.speed = current.avg.toFixed(2);
} }
_cpu_speed = result.speed; _cpu_speed = result.speed;
result.speedmin = ''; result.speedmin = '';
@ -575,8 +575,15 @@ function cpuCurrentspeed(callback) {
return new Promise((resolve) => { return new Promise((resolve) => {
process.nextTick(() => { process.nextTick(() => {
let result = getCpuCurrentSpeedSync(); let result = getCpuCurrentSpeedSync();
if (result === 0 && _cpu_speed !== '0.00') result = parseFloat(_cpu_speed); if (result.avg === 0 && _cpu_speed !== '0.00') {
const currCpuSpeed = parseFloat(_cpu_speed);
result = {
min: currCpuSpeed,
max: currCpuSpeed,
avg: currCpuSpeed,
cores: []
}
}
if (callback) { callback(result); } if (callback) { callback(result); }
resolve(result); resolve(result);
}); });