-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpufreq-setup-PE
More file actions
executable file
·57 lines (50 loc) · 1.34 KB
/
cpufreq-setup-PE
File metadata and controls
executable file
·57 lines (50 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check availability :
if [ cpufreq-set ]
then
echo ""
else
echo -e "${RED} [ERROR] cpufreq-set not found. Try installing... ${NC} \n"
echo "`sudo apt install cpufrequtils`"
fi
# Count CPUs :
MAX_CPU=$((`nproc --all` - 1))
CPU_FOUND=$((MAX_CPU + 1))
echo -e "${YELLOW} [INFO] Found ${CPU_FOUND} CPUs.\n"
#
# I discovered that AMD Ryzen 7840H CPU has a fixed
# frequency at 544Mhz for both Min/Max to be stable.
#
# Meanwhile, most Intel since gen 6th can scale-down
# to exactly 400Mhz - which is great.
#
MIN="400Mhz"
#
# And the maximum clock of my old lappy, which made me
# feel comfortable was only clocked at 3.2GHz.
#
# We can resemble modern Intel with P+E architecture
# by using only 2P-cores + rest as E-cores.
#
P_MAX="3200Mhz"
# Let's check for customization :
# > cpufreq-setup-PE MIN P_MAX
if [ $# -eq 2 ]
then
MIN="$1Mhz"
P_MAX="$2Mhz"
fi
# Here is how it happens :
# > Set 2 first cores[0+1] as "P-core" within P_MAX range [400~3200]Mhz if no user-input.
# > Set the rest of cores to MIN range [400~400]Mhz.
#
for i in $(seq 0 $MAX_CPU); do
[[ $i -lt 1 ]] && MAX_OPTION=$P_MAX || MAX_OPTION=$MIN
echo -e "${GREEN} [cpufreq-set]: CPU #" $i " >> [" $MIN "~" $MAX_OPTION "]${NC}";
sudo cpufreq-set -c $i --min $MIN --max $MAX_OPTION;
done