[Sugar-devel] [PATCH] Add cpu and memory resource indicator to frame

Paul Fox pgf at laptop.org
Fri Jul 2 08:36:43 EDT 2010


i know people don't like to think about queues, and load
averages, but the unix load average numbers give a much better
picture of how hard your system is being asked to work than
instantaneous CPU utilization.  CPU utilization makes for pretty
bar graphs though, so i suppose it will always win.

as an extra benefit, the 1-minute load average is pre-calculated,
available with a read of a single field from /proc/loadavg.

paul

sascha wrote:
 > > +            self.proc_stat_new = self.__getTimeList()
 > If you make all the other attributes private, you should make proc_stat_*
 > private as well.
 > You can probably even git rid of storing proc_stat_new in the instance
 > at all - it doesn't need to be accessible across iterations (= timer
 > callback invocations).
 > 
 > > +            for i in range(len(self.proc_stat_new)) :
 > > +                self.proc_stat_new[i] -= self.proc_stat_old[i]
 > A better set of variable names might help understanding what this does
 > and why it is necessary (/proc/stat entries are absolute times in
 > USER_HZ units). cpu_time_counts might be a start.
 > 
 > > +            cpu_free = (self.proc_stat_new[len(self.proc_stat_new) - 1] * 100.00 /
 > > +                    sum(self.proc_stat_new))
 > 
 > This equates to (iowait * 100) / (user + nice + system + idle + iowait),
 > so it's the percentage of time spent in iowait. I don't think it's a
 > useful figure for how busy (or idle) the CPU is.
 > If we decide not to split up iowait (it indicates permanent storage
 > activity, which we don't have an indicator for on XO-1) and idle,
 > we should at least add them:
 > 
 >         cpu_times_current = [new - old
 >             for new, old in zip(cpu_time_counts_new, self._cpu_time_counts)]
 >         user, nice, system, idle, iowait = cpu_times_current
 >         cpu_free = (idle + iowait) * 100 / sum(cpu_times_current)
 > 

=---------------------
 paul fox, pgf at laptop.org


More information about the Sugar-devel mailing list