mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-28 08:04:27 +02:00
other: update default config generation to show cache (#1102)
This commit is contained in:
parent
513024aefd
commit
8c6ae3bbc7
@ -504,7 +504,7 @@ pub const DEFAULT_BATTERY_LAYOUT: &str = r##"
|
|||||||
// Config and flags
|
// Config and flags
|
||||||
pub const DEFAULT_CONFIG_FILE_PATH: &str = "bottom/bottom.toml";
|
pub const DEFAULT_CONFIG_FILE_PATH: &str = "bottom/bottom.toml";
|
||||||
|
|
||||||
// TODO: Eventually deprecate this.
|
// TODO: Eventually deprecate this, or grab from a file.
|
||||||
pub const CONFIG_TEXT: &str = r##"# This is a default config file for bottom. All of the settings are commented
|
pub const CONFIG_TEXT: &str = r##"# This is a default config file for bottom. All of the settings are commented
|
||||||
# out by default; if you wish to change them uncomment and modify as you see
|
# out by default; if you wish to change them uncomment and modify as you see
|
||||||
# fit.
|
# fit.
|
||||||
@ -582,6 +582,8 @@ pub const CONFIG_TEXT: &str = r##"# This is a default config file for bottom. A
|
|||||||
#disable_advanced_kill = false
|
#disable_advanced_kill = false
|
||||||
# Shows GPU(s) memory
|
# Shows GPU(s) memory
|
||||||
#enable_gpu_memory = false
|
#enable_gpu_memory = false
|
||||||
|
# Shows cache and buffer memory
|
||||||
|
#enable_cache_memory = false
|
||||||
# How much data is stored at once in terms of time.
|
# How much data is stored at once in terms of time.
|
||||||
#retention = "10m"
|
#retention = "10m"
|
||||||
|
|
||||||
|
@ -301,21 +301,20 @@ pub fn convert_mem_label(harvest: &MemHarvest) -> Option<(String, String)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_rx_tx_data_points(
|
pub fn get_rx_tx_data_points(
|
||||||
current_data: &DataCollection, network_scale_type: &AxisScaling, network_unit_type: &DataUnit,
|
data: &DataCollection, scale_type: &AxisScaling, unit_type: &DataUnit, use_binary_prefix: bool,
|
||||||
network_use_binary_prefix: bool,
|
|
||||||
) -> (Vec<Point>, Vec<Point>) {
|
) -> (Vec<Point>, Vec<Point>) {
|
||||||
let mut rx: Vec<Point> = Vec::new();
|
let mut rx: Vec<Point> = Vec::new();
|
||||||
let mut tx: Vec<Point> = Vec::new();
|
let mut tx: Vec<Point> = Vec::new();
|
||||||
|
|
||||||
let current_time = current_data.current_instant;
|
let current_time = data.current_instant;
|
||||||
|
|
||||||
for (time, data) in ¤t_data.timed_data_vec {
|
for (time, data) in &data.timed_data_vec {
|
||||||
let time_from_start: f64 = (current_time.duration_since(*time).as_millis() as f64).floor();
|
let time_from_start: f64 = (current_time.duration_since(*time).as_millis() as f64).floor();
|
||||||
|
|
||||||
let (rx_data, tx_data) = match network_scale_type {
|
let (rx_data, tx_data) = match scale_type {
|
||||||
AxisScaling::Log => {
|
AxisScaling::Log => {
|
||||||
if network_use_binary_prefix {
|
if use_binary_prefix {
|
||||||
match network_unit_type {
|
match unit_type {
|
||||||
DataUnit::Byte => {
|
DataUnit::Byte => {
|
||||||
// As dividing by 8 is equal to subtracting 4 in base 2!
|
// As dividing by 8 is equal to subtracting 4 in base 2!
|
||||||
((data.rx_data).log2() - 4.0, (data.tx_data).log2() - 4.0)
|
((data.rx_data).log2() - 4.0, (data.tx_data).log2() - 4.0)
|
||||||
@ -323,7 +322,7 @@ pub fn get_rx_tx_data_points(
|
|||||||
DataUnit::Bit => ((data.rx_data).log2(), (data.tx_data).log2()),
|
DataUnit::Bit => ((data.rx_data).log2(), (data.tx_data).log2()),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
match network_unit_type {
|
match unit_type {
|
||||||
DataUnit::Byte => {
|
DataUnit::Byte => {
|
||||||
((data.rx_data / 8.0).log10(), (data.tx_data / 8.0).log10())
|
((data.rx_data / 8.0).log10(), (data.tx_data / 8.0).log10())
|
||||||
}
|
}
|
||||||
@ -331,7 +330,7 @@ pub fn get_rx_tx_data_points(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AxisScaling::Linear => match network_unit_type {
|
AxisScaling::Linear => match unit_type {
|
||||||
DataUnit::Byte => (data.rx_data / 8.0, data.tx_data / 8.0),
|
DataUnit::Byte => (data.rx_data / 8.0, data.tx_data / 8.0),
|
||||||
DataUnit::Bit => (data.rx_data, data.tx_data),
|
DataUnit::Bit => (data.rx_data, data.tx_data),
|
||||||
},
|
},
|
||||||
@ -348,38 +347,33 @@ pub fn get_rx_tx_data_points(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn convert_network_data_points(
|
pub fn convert_network_data_points(
|
||||||
current_data: &DataCollection, need_four_points: bool, network_scale_type: &AxisScaling,
|
data: &DataCollection, need_four_points: bool, scale_type: &AxisScaling, unit_type: &DataUnit,
|
||||||
network_unit_type: &DataUnit, network_use_binary_prefix: bool,
|
use_binary_prefix: bool,
|
||||||
) -> ConvertedNetworkData {
|
) -> ConvertedNetworkData {
|
||||||
let (rx, tx) = get_rx_tx_data_points(
|
let (rx, tx) = get_rx_tx_data_points(data, scale_type, unit_type, use_binary_prefix);
|
||||||
current_data,
|
|
||||||
network_scale_type,
|
|
||||||
network_unit_type,
|
|
||||||
network_use_binary_prefix,
|
|
||||||
);
|
|
||||||
|
|
||||||
let unit = match network_unit_type {
|
let unit = match unit_type {
|
||||||
DataUnit::Byte => "B/s",
|
DataUnit::Byte => "B/s",
|
||||||
DataUnit::Bit => "b/s",
|
DataUnit::Bit => "b/s",
|
||||||
};
|
};
|
||||||
|
|
||||||
let (rx_data, tx_data, total_rx_data, total_tx_data) = match network_unit_type {
|
let (rx_data, tx_data, total_rx_data, total_tx_data) = match unit_type {
|
||||||
DataUnit::Byte => (
|
DataUnit::Byte => (
|
||||||
current_data.network_harvest.rx / 8,
|
data.network_harvest.rx / 8,
|
||||||
current_data.network_harvest.tx / 8,
|
data.network_harvest.tx / 8,
|
||||||
current_data.network_harvest.total_rx / 8,
|
data.network_harvest.total_rx / 8,
|
||||||
current_data.network_harvest.total_tx / 8,
|
data.network_harvest.total_tx / 8,
|
||||||
),
|
),
|
||||||
DataUnit::Bit => (
|
DataUnit::Bit => (
|
||||||
current_data.network_harvest.rx,
|
data.network_harvest.rx,
|
||||||
current_data.network_harvest.tx,
|
data.network_harvest.tx,
|
||||||
current_data.network_harvest.total_rx / 8, // We always make this bytes...
|
data.network_harvest.total_rx / 8, // We always make this bytes...
|
||||||
current_data.network_harvest.total_tx / 8,
|
data.network_harvest.total_tx / 8,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
let (rx_converted_result, total_rx_converted_result): ((f64, String), (f64, &'static str)) =
|
let (rx_converted_result, total_rx_converted_result): ((f64, String), (f64, &'static str)) =
|
||||||
if network_use_binary_prefix {
|
if use_binary_prefix {
|
||||||
(
|
(
|
||||||
get_binary_prefix(rx_data, unit), /* If this isn't obvious why there's two functions, one you can configure the unit, the other is always bytes */
|
get_binary_prefix(rx_data, unit), /* If this isn't obvious why there's two functions, one you can configure the unit, the other is always bytes */
|
||||||
get_binary_bytes(total_rx_data),
|
get_binary_bytes(total_rx_data),
|
||||||
@ -392,7 +386,7 @@ pub fn convert_network_data_points(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let (tx_converted_result, total_tx_converted_result): ((f64, String), (f64, &'static str)) =
|
let (tx_converted_result, total_tx_converted_result): ((f64, String), (f64, &'static str)) =
|
||||||
if network_use_binary_prefix {
|
if use_binary_prefix {
|
||||||
(
|
(
|
||||||
get_binary_prefix(tx_data, unit),
|
get_binary_prefix(tx_data, unit),
|
||||||
get_binary_bytes(total_tx_data),
|
get_binary_bytes(total_tx_data),
|
||||||
@ -426,12 +420,12 @@ pub fn convert_network_data_points(
|
|||||||
} else {
|
} else {
|
||||||
let rx_display = format!(
|
let rx_display = format!(
|
||||||
"RX: {:<10} All: {}",
|
"RX: {:<10} All: {}",
|
||||||
if network_use_binary_prefix {
|
if use_binary_prefix {
|
||||||
format!("{:.1}{:3}", rx_converted_result.0, rx_converted_result.1)
|
format!("{:.1}{:3}", rx_converted_result.0, rx_converted_result.1)
|
||||||
} else {
|
} else {
|
||||||
format!("{:.1}{:2}", rx_converted_result.0, rx_converted_result.1)
|
format!("{:.1}{:2}", rx_converted_result.0, rx_converted_result.1)
|
||||||
},
|
},
|
||||||
if network_use_binary_prefix {
|
if use_binary_prefix {
|
||||||
format!(
|
format!(
|
||||||
"{:.1}{:3}",
|
"{:.1}{:3}",
|
||||||
total_rx_converted_result.0, total_rx_converted_result.1
|
total_rx_converted_result.0, total_rx_converted_result.1
|
||||||
@ -445,12 +439,12 @@ pub fn convert_network_data_points(
|
|||||||
);
|
);
|
||||||
let tx_display = format!(
|
let tx_display = format!(
|
||||||
"TX: {:<10} All: {}",
|
"TX: {:<10} All: {}",
|
||||||
if network_use_binary_prefix {
|
if use_binary_prefix {
|
||||||
format!("{:.1}{:3}", tx_converted_result.0, tx_converted_result.1)
|
format!("{:.1}{:3}", tx_converted_result.0, tx_converted_result.1)
|
||||||
} else {
|
} else {
|
||||||
format!("{:.1}{:2}", tx_converted_result.0, tx_converted_result.1)
|
format!("{:.1}{:2}", tx_converted_result.0, tx_converted_result.1)
|
||||||
},
|
},
|
||||||
if network_use_binary_prefix {
|
if use_binary_prefix {
|
||||||
format!(
|
format!(
|
||||||
"{:.1}{:3}",
|
"{:.1}{:3}",
|
||||||
total_tx_converted_result.0, total_tx_converted_result.1
|
total_tx_converted_result.0, total_tx_converted_result.1
|
||||||
|
@ -34,7 +34,7 @@ use app::{
|
|||||||
data_harvester,
|
data_harvester,
|
||||||
frozen_state::FrozenState,
|
frozen_state::FrozenState,
|
||||||
layout_manager::{UsedWidgets, WidgetDirection},
|
layout_manager::{UsedWidgets, WidgetDirection},
|
||||||
App,
|
App, AppConfigFields, DataFilters,
|
||||||
};
|
};
|
||||||
use constants::*;
|
use constants::*;
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
@ -84,7 +84,7 @@ pub enum BottomEvent {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ThreadControlEvent {
|
pub enum ThreadControlEvent {
|
||||||
Reset,
|
Reset,
|
||||||
UpdateConfig(Box<app::AppConfigFields>),
|
UpdateConfig(Box<AppConfigFields>),
|
||||||
UpdateUsedWidgets(Box<UsedWidgets>),
|
UpdateUsedWidgets(Box<UsedWidgets>),
|
||||||
UpdateUpdateTime(u64),
|
UpdateUpdateTime(u64),
|
||||||
}
|
}
|
||||||
@ -484,8 +484,7 @@ pub fn create_input_thread(
|
|||||||
pub fn create_collection_thread(
|
pub fn create_collection_thread(
|
||||||
sender: Sender<BottomEvent>, control_receiver: Receiver<ThreadControlEvent>,
|
sender: Sender<BottomEvent>, control_receiver: Receiver<ThreadControlEvent>,
|
||||||
termination_ctrl_lock: Arc<Mutex<bool>>, termination_ctrl_cvar: Arc<Condvar>,
|
termination_ctrl_lock: Arc<Mutex<bool>>, termination_ctrl_cvar: Arc<Condvar>,
|
||||||
app_config_fields: &app::AppConfigFields, filters: app::DataFilters,
|
app_config_fields: &AppConfigFields, filters: DataFilters, used_widget_set: UsedWidgets,
|
||||||
used_widget_set: UsedWidgets,
|
|
||||||
) -> JoinHandle<()> {
|
) -> JoinHandle<()> {
|
||||||
let temp_type = app_config_fields.temperature_type;
|
let temp_type = app_config_fields.temperature_type;
|
||||||
let use_current_cpu_total = app_config_fields.use_current_cpu_total;
|
let use_current_cpu_total = app_config_fields.use_current_cpu_total;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user