mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-27 07:34:27 +02:00
added --enable_cache_memory flag, disabled cache memory collection by default
This commit is contained in:
parent
69e1783bfb
commit
e6fc69b1df
@ -60,6 +60,7 @@ pub struct AppConfigFields {
|
|||||||
pub table_gap: u16,
|
pub table_gap: u16,
|
||||||
pub disable_click: bool,
|
pub disable_click: bool,
|
||||||
pub enable_gpu_memory: bool,
|
pub enable_gpu_memory: bool,
|
||||||
|
pub enable_cache_memory: bool,
|
||||||
pub show_table_scroll_position: bool,
|
pub show_table_scroll_position: bool,
|
||||||
pub is_advanced_kill: bool,
|
pub is_advanced_kill: bool,
|
||||||
// TODO: Remove these, move network details state-side.
|
// TODO: Remove these, move network details state-side.
|
||||||
|
@ -401,10 +401,12 @@ impl DataCollector {
|
|||||||
fn update_memory_usage(&mut self) {
|
fn update_memory_usage(&mut self) {
|
||||||
if self.widgets_to_harvest.use_mem {
|
if self.widgets_to_harvest.use_mem {
|
||||||
self.data.memory = memory::get_ram_usage(&self.sys);
|
self.data.memory = memory::get_ram_usage(&self.sys);
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
{
|
if self.widgets_to_harvest.use_cache {
|
||||||
self.data.cache = memory::get_cache_usage(&self.sys);
|
self.data.cache = memory::get_cache_usage(&self.sys);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.data.swap = memory::get_swap_usage(
|
self.data.swap = memory::get_swap_usage(
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
&self.sys,
|
&self.sys,
|
||||||
|
@ -997,6 +997,7 @@ Supported widget names:
|
|||||||
pub struct UsedWidgets {
|
pub struct UsedWidgets {
|
||||||
pub use_cpu: bool,
|
pub use_cpu: bool,
|
||||||
pub use_mem: bool,
|
pub use_mem: bool,
|
||||||
|
pub use_cache: bool,
|
||||||
pub use_gpu: bool,
|
pub use_gpu: bool,
|
||||||
pub use_net: bool,
|
pub use_net: bool,
|
||||||
pub use_proc: bool,
|
pub use_proc: bool,
|
||||||
|
@ -441,6 +441,14 @@ use CPU (3) as the default instead.
|
|||||||
app = app.arg(enable_gpu_memory);
|
app = app.arg(enable_gpu_memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
{
|
||||||
|
let cache = Arg::new("enable_cache_memory")
|
||||||
|
.long("enable_cache_memory")
|
||||||
|
.help("Enable collecting and displaying cache and buffer memory.");
|
||||||
|
app = app.arg(cache);
|
||||||
|
}
|
||||||
|
|
||||||
app
|
app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ pub struct ConfigFlags {
|
|||||||
pub network_use_log: Option<bool>,
|
pub network_use_log: Option<bool>,
|
||||||
pub network_use_binary_prefix: Option<bool>,
|
pub network_use_binary_prefix: Option<bool>,
|
||||||
pub enable_gpu_memory: Option<bool>,
|
pub enable_gpu_memory: Option<bool>,
|
||||||
|
pub enable_cache_memory: Option<bool>,
|
||||||
#[serde(with = "humantime_serde")]
|
#[serde(with = "humantime_serde")]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub retention: Option<Duration>,
|
pub retention: Option<Duration>,
|
||||||
@ -236,6 +237,7 @@ pub fn build_app(
|
|||||||
table_gap: u16::from(!(is_flag_enabled!(hide_table_gap, matches, config))),
|
table_gap: u16::from(!(is_flag_enabled!(hide_table_gap, matches, config))),
|
||||||
disable_click: is_flag_enabled!(disable_click, matches, config),
|
disable_click: is_flag_enabled!(disable_click, matches, config),
|
||||||
enable_gpu_memory: get_enable_gpu_memory(matches, config),
|
enable_gpu_memory: get_enable_gpu_memory(matches, config),
|
||||||
|
enable_cache_memory: get_enable_cache_memory(matches, config),
|
||||||
show_table_scroll_position: is_flag_enabled!(show_table_scroll_position, matches, config),
|
show_table_scroll_position: is_flag_enabled!(show_table_scroll_position, matches, config),
|
||||||
is_advanced_kill,
|
is_advanced_kill,
|
||||||
network_scale_type,
|
network_scale_type,
|
||||||
@ -383,6 +385,7 @@ pub fn build_app(
|
|||||||
let used_widgets = UsedWidgets {
|
let used_widgets = UsedWidgets {
|
||||||
use_cpu: used_widget_set.get(&Cpu).is_some() || used_widget_set.get(&BasicCpu).is_some(),
|
use_cpu: used_widget_set.get(&Cpu).is_some() || used_widget_set.get(&BasicCpu).is_some(),
|
||||||
use_mem,
|
use_mem,
|
||||||
|
use_cache: use_mem && get_enable_cache_memory(matches, config),
|
||||||
use_gpu: use_mem && get_enable_gpu_memory(matches, config),
|
use_gpu: use_mem && get_enable_gpu_memory(matches, config),
|
||||||
use_net: used_widget_set.get(&Net).is_some() || used_widget_set.get(&BasicNet).is_some(),
|
use_net: used_widget_set.get(&Net).is_some() || used_widget_set.get(&BasicNet).is_some(),
|
||||||
use_proc: used_widget_set.get(&Proc).is_some(),
|
use_proc: used_widget_set.get(&Proc).is_some(),
|
||||||
@ -713,6 +716,22 @@ fn get_enable_gpu_memory(matches: &ArgMatches, config: &Config) -> bool {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
fn get_enable_cache_memory(matches: &ArgMatches, config: &Config) -> bool {
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
{
|
||||||
|
if matches.contains_id("enable_cache_memory") {
|
||||||
|
return true;
|
||||||
|
} else if let Some(flags) = &config.flags {
|
||||||
|
if let Some(enable_cache_memory) = flags.enable_cache_memory {
|
||||||
|
return enable_cache_memory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
fn get_ignore_list(ignore_list: &Option<IgnoreList>) -> error::Result<Option<Filter>> {
|
fn get_ignore_list(ignore_list: &Option<IgnoreList>) -> error::Result<Option<Filter>> {
|
||||||
if let Some(ignore_list) = ignore_list {
|
if let Some(ignore_list) = ignore_list {
|
||||||
let list: Result<Vec<_>, _> = ignore_list
|
let list: Result<Vec<_>, _> = ignore_list
|
||||||
|
Loading…
x
Reference in New Issue
Block a user