Skip to content

Commit

Permalink
Modified fixed cpu usage percentage (#99)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
rrodriguez81 and rrodriguez81 committed Aug 31, 2020
1 parent 49d3421 commit 5e6139b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/core.py
Expand Up @@ -9,6 +9,7 @@
import sys
import time
import warnings
from math import isclose
from pathlib import Path
from pprint import pformat
from subprocess import getoutput, call, run
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 5e6139b

Please sign in to comment.