From ca966e2de8f0767b8aa6dea2e37561613f06172e Mon Sep 17 00:00:00 2001 From: rrodriguez81 <70445358+rrodriguez81@users.noreply.github.com> Date: Mon, 31 Aug 2020 22:44:11 +0200 Subject: [PATCH] Modified fixed cpu usage percentage (#99) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- source/core.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/core.py b/source/core.py index 3b3e322..5d18184 100644 --- a/source/core.py +++ b/source/core.py @@ -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: