|
2 | 2 |
|
3 | 3 | # Check CPU tuning on Linux — poor settings cause massive variance |
4 | 4 | hw_warnings="" |
| 5 | +hw_fixes=() |
5 | 6 |
|
6 | 7 | if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]; then |
7 | 8 | gov=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) |
8 | 9 | if [ "$gov" != "performance" ]; then |
9 | 10 | hw_warnings+="⚠️ CPU governor is '$gov' — benchmark results will be noisy. |
10 | | - Fix with: sudo cpupower frequency-set -g performance |
11 | 11 | " |
| 12 | + hw_fixes+=("sudo cpupower frequency-set -g performance") |
12 | 13 | fi |
13 | 14 | fi |
14 | 15 |
|
15 | 16 | if [ -f /sys/devices/system/cpu/cpufreq/boost ]; then |
16 | 17 | boost=$(cat /sys/devices/system/cpu/cpufreq/boost) |
17 | 18 | if [ "$boost" = "1" ]; then |
18 | 19 | hw_warnings+="⚠️ CPU boost is enabled — frequency varies with thermals. |
19 | | - Fix with: echo 0 | sudo tee /sys/devices/system/cpu/cpufreq/boost |
20 | 20 | " |
| 21 | + hw_fixes+=("echo 0 | sudo tee /sys/devices/system/cpu/cpufreq/boost") |
| 22 | + fi |
| 23 | +elif [ -f /sys/devices/system/cpu/intel_pstate/no_turbo ]; then |
| 24 | + no_turbo=$(cat /sys/devices/system/cpu/intel_pstate/no_turbo) |
| 25 | + if [ "$no_turbo" = "0" ]; then |
| 26 | + hw_warnings+="⚠️ Intel Turbo Boost is enabled — frequency varies with thermals. |
| 27 | +" |
| 28 | + hw_fixes+=("echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo") |
21 | 29 | fi |
22 | 30 | fi |
23 | 31 |
|
24 | 32 | if [ -n "$hw_warnings" ]; then |
25 | 33 | echo "" |
26 | 34 | echo "$hw_warnings" |
| 35 | + |
| 36 | + if [ ${#hw_fixes[@]} -gt 0 ] && [ -t 0 ]; then |
| 37 | + echo "Fix with:" |
| 38 | + for fix in "${hw_fixes[@]}"; do |
| 39 | + echo " $fix" |
| 40 | + done |
| 41 | + echo "" |
| 42 | + read -rp "Apply these fixes now? [y/N] " answer |
| 43 | + if [[ "$answer" =~ ^[Yy]$ ]]; then |
| 44 | + for fix in "${hw_fixes[@]}"; do |
| 45 | + echo "→ $fix" |
| 46 | + eval "$fix" |
| 47 | + done |
| 48 | + echo "" |
| 49 | + echo "✅ CPU tuning applied." |
| 50 | + echo "" |
| 51 | + fi |
| 52 | + fi |
27 | 53 | fi |
28 | 54 |
|
29 | 55 | export BENCH_JSON_OUTPUT=./bench-results.json |
|
0 commit comments