From bb41f1bd105f307165c91e5037f4db7b1619a560 Mon Sep 17 00:00:00 2001 From: Mattia Procopio Date: Tue, 11 Jan 2022 16:17:42 +0100 Subject: [PATCH] Try to reduce CPU utilization by not fetching all (#11) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/main.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0882ceb..f2a4546 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -447,9 +447,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.22.3" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b645b59c59114c25d3d554f781b0a1f1f01545d1d02f271bfb1c897bdfdfdcf3" +checksum = "7f1bfab07306a27332451a662ca9c8156e3a9986f82660ba9c8e744fe8455d43" dependencies = [ "cfg-if", "core-foundation-sys", diff --git a/Cargo.toml b/Cargo.toml index e40bfac..bb6d6c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] minreq = { version = "2.4.2", features = ["https"] } -sysinfo = "0.22.3" +sysinfo = "0.22.5" structopt = { version = "0.3", default-features = false } dirs = "4.0" chrono = "0.4.19" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 799dc7e..fec3530 100644 --- a/src/main.rs +++ b/src/main.rs @@ -143,8 +143,8 @@ fn main() -> Result<(), Error> { let start_time: String = chrono::Local::now().to_rfc3339_opts(SecondsFormat::Secs, false); loop { - system.refresh_all(); - let kstars_proc = system.process_by_name("kstars"); + system.refresh_processes(); + let kstars_proc = system.process_by_exact_name("kstars"); if kstars_proc.is_empty() { let _resp = notify_via_telegram(&api_token)?; };