diff options
author | 2022-04-14 02:11:43 -0300 | |
---|---|---|
committer | 2022-04-26 18:59:08 -0300 | |
commit | c9ea1f11dec96df04ade463ea9f33062a85c9219 (patch) | |
tree | fcdf29f469d18dfdc3b3ab40d7e6b2491a416194 /winit | |
parent | 5bfe887e3d4acb2c48cca22c73aa52f4cc4856ad (diff) | |
download | iced-c9ea1f11dec96df04ade463ea9f33062a85c9219.tar.gz iced-c9ea1f11dec96df04ade463ea9f33062a85c9219.tar.bz2 iced-c9ea1f11dec96df04ade463ea9f33062a85c9219.zip |
Add memory usage to `Information` struct
Diffstat (limited to 'winit')
-rw-r--r-- | winit/src/application.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index 9d65d769..1865f344 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -584,12 +584,21 @@ pub fn run_command<Message: 'static + std::fmt::Debug + Send, E: Executor>( system::Action::QueryInformation(tag) => { #[cfg(feature = "sysinfo")] let information = { - use sysinfo::{ProcessorExt, System, SystemExt}; + use sysinfo::{ + ProcessExt, ProcessorExt, System, SystemExt, + }; let mut system = System::new_all(); system.refresh_all(); let cpu = system.global_processor_info(); + let memory_used = sysinfo::get_current_pid() + .and_then(|pid| { + system.process(pid).ok_or("Process not found") + }) + .and_then(|process| Ok(process.memory())) + .ok(); + let information = system::Information { system_name: system.name(), system_kernel: system.kernel_version(), @@ -597,6 +606,7 @@ pub fn run_command<Message: 'static + std::fmt::Debug + Send, E: Executor>( cpu_brand: cpu.brand().into(), cpu_cores: system.physical_core_count(), memory_total: system.total_memory(), + memory_used, graphics_adapter: graphics_info.adapter.clone(), graphics_backend: graphics_info.backend.clone(), }; |