diff options
author | pdw <> | 2002-10-25 15:51:59 +0000 |
---|---|---|
committer | pdw <> | 2002-10-25 15:51:59 +0000 |
commit | c7f1e02a4e7ec7ee1b2595b9b9e1ec0d0b286db9 (patch) | |
tree | 8c42247c4ff6f1afa017ad3cbfa1c6f2eae5a77c /ui.c | |
parent | 5aab35fd99ed1a293967084f67035302a027e1d7 (diff) | |
download | iftop-c7f1e02a4e7ec7ee1b2595b9b9e1ec0d0b286db9.zip |
Unbroke bar graph scales. bits vs bytes. Argh.
Diffstat (limited to 'ui.c')
-rw-r--r-- | ui.c | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -187,16 +187,17 @@ void readable_size(float n, char* buf, int bsize, int ksize, int bytes) { static struct { int max, interval; } scale[] = { - { 8000, 10 }, /* 64 kbit/s */ - { 16000, 10 }, - { 32000, 10 }, - { 125000, 10 }, /* 1 Mbit/s */ - { 1250000, 10 }, - { 12500000, 100 }, - { 125000000, 100 } /* 1 Gbit/s */ + { 64000, 10 }, /* 64 kbit/s */ + { 128000, 10 }, + { 256000, 10 }, + { 1000000, 10 }, /* 1 Mbit/s */ + { 10000000, 10 }, + { 100000000, 100 }, + { 1000000000, 100 } /* 1 Gbit/s */ }; static int rateidx = 0, wantbiggerrate; +/* rate in bits */ static int get_bar_length(const int rate) { float l; if (rate <= 0) @@ -208,18 +209,19 @@ static int get_bar_length(const int rate) { } static void draw_bar_scale(int* y) { - int i; + float i; if(options.showbars) { /* Draw bar graph scale on top of the window. */ move(*y, 0); clrtoeol(); mvhline(*y + 1, 0, 0, COLS); - for (i = 1; i <= scale[rateidx].max; i *= scale[rateidx].interval) { + /* i in bytes */ + for (i = 1.25; i * 8 <= scale[rateidx].max; i *= scale[rateidx].interval) { char s[40], *p; int x; readable_size(i, s, sizeof s, 1000, 0); p = s + strspn(s, " "); - x = get_bar_length(i); + x = get_bar_length(i * 8); mvaddch(*y + 1, x, ACS_BTEE); if (x + strlen(p) >= COLS) x = COLS - strlen(p); |