wmmon: Properly compute height of system load window.
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.
This commit is contained in:
parent
d56480c377
commit
7354c4df53
|
@ -910,7 +910,7 @@ void DrawStats(int *his, int num, int size, int x_left, int y_bottom)
|
|||
p = his;
|
||||
|
||||
for (j=0; j<num; j++) {
|
||||
if (p[0] > pixels_per_byte)
|
||||
while (p[0] > pixels_per_byte)
|
||||
pixels_per_byte += 100;
|
||||
p += 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue