Mercurial > controlcenter
changeset 82:d1217903b66c
Linux/Android: Make logic more clean, and cap load at 100% when using the
load averages instead of actual CPU load.
author | Brian Smith <brian@dbsoft.org> |
---|---|
date | Tue, 24 Aug 2021 20:19:55 -0500 |
parents | 4acd9b9d3555 |
children | 4ceb8271a180 |
files | statsunx.c |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/statsunx.c Tue Aug 24 19:16:19 2021 -0500 +++ b/statsunx.c Tue Aug 24 20:19:55 2021 -0500 @@ -108,13 +108,13 @@ { int cpucores = get_nprocs(); float f_load = 1.f / (1 << SI_LOAD_SHIFT); - double onemin = (double)si.loads[0] * f_load; + double onemin = ((double)si.loads[0]) * (double)f_load; - if(cpucores > 0) + if(cpucores > 1) *Load = onemin / ((double)cpucores); - else if (onemin < 1.0) + else *Load = onemin; - else + if(*Load > 1.0) *Load = 1.0; } }