Skip to content

Instantly share code, notes, and snippets.

@oneman
Created February 18, 2013 10:35
Show Gist options
  • Save oneman/4976508 to your computer and use it in GitHub Desktop.
Save oneman/4976508 to your computer and use it in GitHub Desktop.
#!/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