mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-22 20:23:12 +00:00
Removed btreemap and went back to vec as it makes more sense for us
This commit is contained in:
parent
e6b6048afb
commit
fe99b99d0a
2 changed files with 7 additions and 16 deletions
|
@ -119,13 +119,9 @@ impl DataState {
|
|||
|
||||
let joining_points: Option<Vec<network::NetworkJoinPoint>> =
|
||||
if !self.data.network.data_points.is_empty() {
|
||||
if let Some(prev_data) = self
|
||||
.data
|
||||
.network
|
||||
.data_points
|
||||
.get(&self.data.network.last_collection_time)
|
||||
{
|
||||
if let Some(last_entry) = self.data.network.data_points.last() {
|
||||
// If not empty, inject joining points
|
||||
let prev_data = &last_entry.1;
|
||||
let rx_diff = new_network_data.rx as f64 - prev_data.0.rx as f64;
|
||||
let tx_diff = new_network_data.tx as f64 - prev_data.0.tx as f64;
|
||||
let time_gap = current_instant
|
||||
|
@ -161,7 +157,7 @@ impl DataState {
|
|||
self.data
|
||||
.network
|
||||
.data_points
|
||||
.insert(current_instant, (new_network_data, joining_points));
|
||||
.push((current_instant, (new_network_data, joining_points)));
|
||||
|
||||
// What we want to do: For timed data, if there is an error, just do not add. For other data, just don't update!
|
||||
push_if_valid(
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use futures::StreamExt;
|
||||
use heim::net;
|
||||
use heim::units::information::byte;
|
||||
use std::collections::BTreeMap;
|
||||
use std::time::Instant;
|
||||
use sysinfo::{NetworkExt, System, SystemExt};
|
||||
|
||||
|
@ -12,9 +11,10 @@ pub struct NetworkJoinPoint {
|
|||
pub time_offset_milliseconds: f64,
|
||||
}
|
||||
|
||||
type NetworkDataGroup = (Instant, (NetworkData, Option<Vec<NetworkJoinPoint>>));
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct NetworkStorage {
|
||||
pub data_points: BTreeMap<Instant, (NetworkData, Option<Vec<NetworkJoinPoint>>)>,
|
||||
pub data_points: Vec<NetworkDataGroup>,
|
||||
pub rx: u64,
|
||||
pub tx: u64,
|
||||
pub total_rx: u64,
|
||||
|
@ -25,7 +25,7 @@ pub struct NetworkStorage {
|
|||
impl Default for NetworkStorage {
|
||||
fn default() -> Self {
|
||||
NetworkStorage {
|
||||
data_points: BTreeMap::default(),
|
||||
data_points: Vec::default(),
|
||||
rx: 0,
|
||||
tx: 0,
|
||||
total_rx: 0,
|
||||
|
@ -37,7 +37,7 @@ impl Default for NetworkStorage {
|
|||
|
||||
impl NetworkStorage {
|
||||
pub fn first_run(&mut self) {
|
||||
self.data_points = BTreeMap::default();
|
||||
self.data_points = Vec::default();
|
||||
self.rx = 0;
|
||||
self.tx = 0;
|
||||
}
|
||||
|
@ -76,11 +76,6 @@ pub async fn get_network_data(
|
|||
.duration_since(*prev_net_access_time)
|
||||
.as_secs_f64();
|
||||
|
||||
debug!(
|
||||
"net rx: {}, net tx: {}, net prev rx: {}, net prev tx: {}",
|
||||
net_rx, net_tx, *prev_net_rx, *prev_net_tx
|
||||
);
|
||||
|
||||
let rx = ((net_rx - *prev_net_rx) as f64 / elapsed_time) as u64;
|
||||
let tx = ((net_tx - *prev_net_tx) as f64 / elapsed_time) as u64;
|
||||
|
||||
|
|
Loading…
Reference in a new issue