lib/knj/cpufreq.rb in knjrbfw-0.0.30 vs lib/knj/cpufreq.rb in knjrbfw-0.0.31

- old
+ new

@@ -1,14 +1,22 @@ #This class can manipulate the CPU behavior through "cpufreq". class Knj::Cpufreq + #Data that is used to identify the CPU controlled by this object. attr_reader :data + #Useually called through "Knj::Cpufreq.list". def initialize(data) @data = data @allowed_govs = ["performance", "ondemand", "powersafe", "conservative"] end + #Returns a list of CPUs. + #===Examples + # list = Knj::Cpufreq.list + # list.each do |cpufreq| + # cpufreq.governor = "performance" + # end def self.list ret = [] cont = File.read("/proc/cpuinfo") matches = cont.scan(/processor\s*:[\s\S]+?\n\n/) @@ -26,9 +34,12 @@ end return ret end + #Sets the governor. + #===Examples + # cpufreq.governor = "performance" def governor=(newgov) raise "Governor not found." if @allowed_govs.index(newgov) == nil cmd = "cpufreq-set --cpu #{@data["processor"]} --governor #{newgov}" res = Knj::Os::shellcmd(cmd) \ No newline at end of file