Created
February 18, 2013 10:35
-
-
Save oneman/4976508 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
governors = ["performance", "ondemand"] | |
def setgov(gov, thread) | |
`echo #{gov} > /sys/devices/system/cpu/cpu#{thread}/cpufreq/scaling_governor` | |
end | |
def showgov(thread) | |
gov = `cat /sys/devices/system/cpu/cpu#{thread}/cpufreq/scaling_governor`.chomp | |
puts "thread #{thread} is on #{gov}" | |
end | |
cores = 4 | |
threads = 2 | |
total = cores * threads | |
hot = 0 | |
while true | |
puts "" | |
puts Time.now.to_s | |
curcore = 0 | |
curthread = 0 | |
cores.times do | |
threads.times do | |
if curcore == hot | |
setgov(governors.first, curthread) | |
else | |
setgov(governors.last, curthread) | |
end | |
showgov(curthread) | |
curthread = curthread + 1 | |
end | |
curcore = curcore + 1 | |
end | |
hot = hot + 1 | |
sleep 6 | |
if hot == cores | |
hot = 0 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment