Previously, a green hint line was drawn on the CPU window for each
multiple of 1. This meant as the load average approached 40 (the
height of the window), the window would gradually fill up entirely
with green.
To get around this, we switch to a yellow hint line for each
multiple of 10 once the load passes 10. And then a red hint line
for each multiple of 100 once the load passes 100.
This fixes Debian bug #894801, reported by Pedro Gimeno
<debian.bts@personal.formauri.es>.
The system load monitor displays green hint lines at every 100 units once
load average rises above 100.
Previously, the vertical position of these lines was computed before
each and every pixel was drawn. But since the horizontal position
isn't needed for this computation, we move it up a level to the
outer for loop.
Previously, we looped through the history and added 100 whenever we found
a larger value. This has a number of problems. In particular,
* We get a maximum possible value of 5500 (100 * the number of values in
the history). It is certainly possible to have a system load north of
this on modern systems.
* If the system load in history were to jump by more than 100 in a single
step, then we wouldn't be adding enough. For example, suppose the
system load in history is 175, and our height was previously computed
to be 200. Suppose the next value in history is 320. We would add
100 to get a new height of 300, which isn't sufficient to display the
320.
The fix is simple -- replace the if statement with a while loop, i.e.,
continue adding 100 until we get a height that fits our value.