mirror of
https://github.com/AdnanHodzic/auto-cpufreq.git
synced 2025-07-25 22:55:04 +02:00
added option to use turbo even in powersave mode under very high load
This commit is contained in:
parent
c31aeaebfe
commit
d9f39f2998
@ -5,10 +5,10 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import psutil
|
import psutil
|
||||||
import cpuinfo
|
#import cpuinfo
|
||||||
import platform
|
import platform
|
||||||
import distro
|
#import distro
|
||||||
import re
|
#import re
|
||||||
#from subprocess import call
|
#from subprocess import call
|
||||||
import click
|
import click
|
||||||
|
|
||||||
@ -22,6 +22,9 @@ import click
|
|||||||
# - add option to enable turbo in powersave
|
# - add option to enable turbo in powersave
|
||||||
# - go thru all other ToDo's
|
# - go thru all other ToDo's
|
||||||
# - make shortcut for platform
|
# - make shortcut for platform
|
||||||
|
# - add boost options on cpu temperature?
|
||||||
|
# - if switch to psutil load (add percentage as well)
|
||||||
|
# - add print which mode is auto-cpufreq running in
|
||||||
|
|
||||||
# global var
|
# global var
|
||||||
p = psutil
|
p = psutil
|
||||||
@ -106,9 +109,12 @@ def set_powersave():
|
|||||||
print("Setting turbo: off")
|
print("Setting turbo: off")
|
||||||
s.run("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
s.run("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
||||||
|
|
||||||
|
# enable turbo boost
|
||||||
|
set_turbo_powersave()
|
||||||
|
|
||||||
# set performance
|
# set performance
|
||||||
def set_performance():
|
def set_performance():
|
||||||
print("Using \"performance\" governor")
|
print("Setting to use \"performance\" governor")
|
||||||
s.run("cpufreqctl --governor --set=performance", shell=True)
|
s.run("cpufreqctl --governor --set=performance", shell=True)
|
||||||
|
|
||||||
# enable turbo boost
|
# enable turbo boost
|
||||||
@ -126,17 +132,42 @@ def set_turbo():
|
|||||||
print("Total system load:", load1m, "\n")
|
print("Total system load:", load1m, "\n")
|
||||||
|
|
||||||
if load1m > 1:
|
if load1m > 1:
|
||||||
print("High load, turbo boost: on")
|
print("High load, setting turbo boost: on")
|
||||||
s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
||||||
footer(79)
|
footer(79)
|
||||||
|
|
||||||
elif cpuload > 20:
|
elif cpuload > 20:
|
||||||
print("High CPU load, turbo boost: on")
|
print("High CPU load, setting turbo boost: on")
|
||||||
s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
||||||
#print("\n" + "-" * 60 + "\n")
|
#print("\n" + "-" * 60 + "\n")
|
||||||
footer(79)
|
footer(79)
|
||||||
else:
|
else:
|
||||||
print("Load optimal, turbo boost: off")
|
print("Load optimal, setting turbo boost: off")
|
||||||
|
s.run("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
||||||
|
#print("\n" + "-" * 60 + "\n")
|
||||||
|
footer(79)
|
||||||
|
|
||||||
|
# set turbo when in powersave
|
||||||
|
def set_turbo_powersave():
|
||||||
|
|
||||||
|
print("\n" + "-" * 5 + "\n")
|
||||||
|
|
||||||
|
# ToDo: duplicate + replace with psutil.getloadavg()? (available in 5.6.2)
|
||||||
|
load1m, _, _ = os.getloadavg()
|
||||||
|
|
||||||
|
print("Total CPU usage:", cpuload, "%")
|
||||||
|
print("Total system load:", load1m, "\n")
|
||||||
|
|
||||||
|
if load1m > 4:
|
||||||
|
print("High load, setting turbo boost: on")
|
||||||
|
s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
||||||
|
footer(79)
|
||||||
|
elif cpuload > 50:
|
||||||
|
print("High CPU load, setting turbo boost: on")
|
||||||
|
s.run("echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
||||||
|
#print("\n" + "-" * 60 + "\n")
|
||||||
|
footer(79)
|
||||||
|
else:
|
||||||
|
print("Load optimal, setting turbo boost: off")
|
||||||
s.run("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
s.run("echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo", shell=True)
|
||||||
#print("\n" + "-" * 60 + "\n")
|
#print("\n" + "-" * 60 + "\n")
|
||||||
footer(79)
|
footer(79)
|
||||||
@ -153,7 +184,7 @@ def mon_turbo():
|
|||||||
print("Total system load:", load1m, "\n")
|
print("Total system load:", load1m, "\n")
|
||||||
|
|
||||||
if load1m > 2:
|
if load1m > 2:
|
||||||
print("High load, suggesting turbo boost: on")
|
print("High load, suggesting to set turbo boost: on")
|
||||||
if cur_turbo == "0":
|
if cur_turbo == "0":
|
||||||
print("Currently turbo boost is: on")
|
print("Currently turbo boost is: on")
|
||||||
else:
|
else:
|
||||||
@ -161,14 +192,14 @@ def mon_turbo():
|
|||||||
footer(79)
|
footer(79)
|
||||||
|
|
||||||
elif cpuload > 25:
|
elif cpuload > 25:
|
||||||
print("High CPU load, suggesting turbo boost: on")
|
print("High CPU load, suggesting to set turbo boost: on")
|
||||||
if cur_turbo == "0":
|
if cur_turbo == "0":
|
||||||
print("Currently turbo boost is: on")
|
print("Currently turbo boost is: on")
|
||||||
else:
|
else:
|
||||||
print("Currently turbo boost is: off")
|
print("Currently turbo boost is: off")
|
||||||
footer(79)
|
footer(79)
|
||||||
else:
|
else:
|
||||||
print("Load optimal, suggesting turbo boost: off")
|
print("Load optimal, suggesting to set turbo boost: off")
|
||||||
if cur_turbo == "0":
|
if cur_turbo == "0":
|
||||||
print("Currently turbo boost is: on")
|
print("Currently turbo boost is: on")
|
||||||
else:
|
else:
|
||||||
@ -179,6 +210,9 @@ def mon_turbo():
|
|||||||
def set_autofreq():
|
def set_autofreq():
|
||||||
print("\n" + "-" * 28 + " CPU frequency scaling " + "-" * 28 + "\n")
|
print("\n" + "-" * 28 + " CPU frequency scaling " + "-" * 28 + "\n")
|
||||||
|
|
||||||
|
# get battery state
|
||||||
|
bat_state = p.sensors_battery().power_plugged
|
||||||
|
|
||||||
# determine which governor should be used
|
# determine which governor should be used
|
||||||
if bat_state == True:
|
if bat_state == True:
|
||||||
print("Battery is: charging")
|
print("Battery is: charging")
|
||||||
@ -193,6 +227,9 @@ def set_autofreq():
|
|||||||
def mon_autofreq():
|
def mon_autofreq():
|
||||||
print("\n" + "-" * 28 + " CPU frequency scaling " + "-" * 28 + "\n")
|
print("\n" + "-" * 28 + " CPU frequency scaling " + "-" * 28 + "\n")
|
||||||
|
|
||||||
|
# get battery state
|
||||||
|
bat_state = p.sensors_battery().power_plugged
|
||||||
|
|
||||||
# determine which governor should be used
|
# determine which governor should be used
|
||||||
if bat_state == True:
|
if bat_state == True:
|
||||||
print("Battery is: charging")
|
print("Battery is: charging")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user