diff options
| -rw-r--r-- | README.md | 2 | ||||
| -rwxr-xr-x | install | 3 | ||||
| -rwxr-xr-x | perfmgr | 71 | ||||
| -rw-r--r-- | rfile | 1 |
4 files changed, 77 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..855f0ad --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# perfmgr +**perf**ormance**m**ana**g**e**r** is an awful python script to trade knowing useful commands for speed @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +sudo cp ./perfmgr /usr/bin/perfmgr +sudo ln -s /usr/bin/perfmgr /usr/bin/pfmgr @@ -0,0 +1,71 @@ +#!/usr/bin/python +import sys +import subprocess + +def system(cmd): + print(f"$ {cmd}") + subprocess.run(cmd, shell=True) + +def usage(): + print(f"usage: {sys.argv[0]} [on|off / turbo[on|off] / info]") + +def main(argv) -> int: + argc = len(argv) + + if argc < 2: + usage() + return 1 + + opt1 = argv[1] + + if argc == 2: + if opt1 == "on": + system("sudo -E cpupower frequency-set -g powersave") + return 0 + elif opt1 == "off": + system("sudo -E cpupower frequency-set -g performance") + return 0 + elif opt1 == "info": + system("cpupower frequency-info") + return 0 + elif opt1 == "-h" or opt1 == "--help": + usage() + return 0 + else: + print(f"unknown option \'{opt1}\'") + return 1 + + elif argc >= 3: + opt2 = argv[2] + + if opt1 == "turbo": + if opt2 == "on": + system("echo 0 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo") + return 0 + elif opt2 == "off": + system("echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo") + return 0 + else: + print(f"unknown option \'{opt2}\' for 'turbo'") + return 1 + else: + if opt1 == "on": + system("sudo -E cpupower frequency-set -g powersave") + return 0 + elif opt1 == "off": + system("sudo -E cpupower frequency-set -g performance") + return 0 + elif opt1 == "info": + system("cpupower frequency-info") + return 0 + elif opt1 == "-h" or opt1 == "--help": + usage() + return 0 + else: + print(f"unknown option \'{opt1}\'") + return 1 + + return 0 + +main(sys.argv) + @@ -0,0 +1 @@ +./install |