Modified fixed cpu usage percentage (#99)

* A fixed value of 25% CPU Load is not correct for enabling turbo, it should be enabled when one thread reach 100%

* A fixed turbo on chargin state

* Improved 1 thread CPU 100% load detection solution

Co-authored-by: Roberto Rodríguez <rrodriguez@datiobd.com>
This commit is contained in:
rrodriguez81 2020-08-31 22:44:11 +02:00 committed by GitHub
parent 5a169a1357
commit c4d7f43803
1 changed files with 4 additions and 3 deletions

View File

@ -9,6 +9,7 @@ import shutil
import sys
import time
import warnings
from math import isclose
from pathlib import Path
from pprint import pformat
from subprocess import getoutput, call, run
@ -303,7 +304,7 @@ def set_powersave():
if load1m > CPUS / 7:
print("High load, setting turbo boost: on")
turbo(True)
elif cpuload > 25:
elif psutil.cpu_percent(percpu=False) >= 25.0 or isclose(max(psutil.cpu_percent(percpu=True)), 100):
print("High CPU load, setting turbo boost: on")
turbo(True)
else:
@ -331,7 +332,7 @@ def mon_powersave():
print("Currently turbo boost is: off")
footer()
elif cpuload > 25:
elif psutil.cpu_percent(percpu=False) >= 25.0 or isclose(max(psutil.cpu_percent(percpu=True)), 100):
print("High CPU load, suggesting to set turbo boost: on")
if turbo():
print("Currently turbo boost is: on")
@ -364,7 +365,7 @@ def set_performance():
if load1m >= CPUS / 5:
print("High load, setting turbo boost: on")
turbo(True)
elif cpuload > 20:
elif psutil.cpu_percent(percpu=False) >= 15.0 or isclose(max(psutil.cpu_percent(percpu=True)), 100):
print("High CPU load, setting turbo boost: on")
turbo(True)
else: