diff options
author | gennyble <gen@nyble.dev> | 2025-03-02 04:12:53 -0600 |
---|---|---|
committer | gennyble <gen@nyble.dev> | 2025-03-02 04:12:53 -0600 |
commit | 077a09f82fd9af39b84b61a056ea269da6464368 (patch) | |
tree | 20ac75b5867c88bde99cba144d998fd865ad24e2 /src/gatherer.rs | |
parent | fef0a6c0eabf4c2471a0f080798dda3bf6017863 (diff) | |
download | awake-077a09f82fd9af39b84b61a056ea269da6464368.tar.gz awake-077a09f82fd9af39b84b61a056ea269da6464368.zip |
Max range in graphs can be below 160; 2 line graphs draw larger first
Diffstat (limited to 'src/gatherer.rs')
-rw-r--r-- | src/gatherer.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/gatherer.rs b/src/gatherer.rs index 53e46f1..c03a0a5 100644 --- a/src/gatherer.rs +++ b/src/gatherer.rs @@ -12,7 +12,7 @@ use time::OffsetDateTime; use crate::{ db::DbMeminfo, - griph::{self, Style}, + griph::{self, Style, TwoLineOrder}, AwakeState, }; @@ -159,6 +159,9 @@ pub fn make_net_graph(state: &AwakeState) { .map(|m| m.map(|n| n.tx_bytes_per_sec() as usize / 125).unwrap_or(0)) .collect(); + let rx_sum = rx_zeroed.iter().fold(0, |acc, x| acc + x); + let tx_sum = tx_zeroed.iter().fold(0, |acc, x| acc + x); + // Mixing the TX/RX delta so we can pick a range. let mut mixed = vec![0; 512]; mixed[..256].copy_from_slice(&rx_zeroed); @@ -166,12 +169,20 @@ pub fn make_net_graph(state: &AwakeState) { mixed.sort(); let kinda_highest = mixed[511 - 32]; - let high_bound = (kinda_highest as f32 / 256.0).ceil().max(1.0) as usize * 256; + let high_bound = (kinda_highest as f32 / 64.0).ceil().max(1.0) as usize * 64; state .netinfo_upper_bound .store(high_bound, Ordering::Release); - let gif = griph::make_2line(0, high_bound, &tx_deltas, &rx_deltas); + let order = if tx_sum > rx_sum { + TwoLineOrder::SeriesAFirst + } else { + TwoLineOrder::SeriesBFirst + }; + + tracing::debug!("tx_sum = {tx_sum} // rx_sum = {rx_sum} // order = {order:?}"); + + let gif = griph::make_2line(0, high_bound, &tx_deltas, &rx_deltas, order); let path = state.cache_path.join("current_hostnetinfo.gif"); gif.save(path).unwrap(); |