Skip to content

Commit

Permalink
net: Switch from KB > MB > GB, switch early
Browse files Browse the repository at this point in the history
  • Loading branch information
iphands committed Nov 28, 2020
1 parent 403ea7d commit 48508d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions config/my_desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ ui:
type: mem_consumers
limit: 5

- text: NETWORKING
type: net
items:
- name: ige00
interface: ige00
- name: mel00
interface: mel00

- text: FILESYSTEM
type: filesystem
items:
Expand Down
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,16 @@ fn update_ui(config: &Yaml, stash: UiStash) {
let mut bytes = (curr_bytes - cache_val.last_bytes) as f64 / 1024.0;
bytes = (bytes * 1000.0) / (cache_val.last_instant.elapsed().as_millis() as f64);

if bytes > 1000.0 {
if bytes > 990.0 {
bytes = bytes / 1024.0;
lbl = "MB";
}

if bytes > 990.0 {
bytes = bytes / 1024.0;
lbl = "GB";
}

cache.insert(String::from(key), NetDevCache {
last_bytes: curr_bytes.clone(),
last_instant: Instant::now(),
Expand Down

0 comments on commit 48508d4

Please sign in to comment.