mirror of
https://github.com/m1ngsama/tracker.git
synced 2025-12-24 10:51:43 +00:00
optimize: improve build profile, CI, and remove redundant cpu sleeps
- Add release profile with LTO and stripping for smaller binaries - Add Rust checks (fmt, clippy, test) to CI - Remove redundant 200ms sleep in cpu monitoring for better continuous performance - Fix dead code warnings in various modules
This commit is contained in:
parent
1194588b7e
commit
9fe4543aa6
6 changed files with 31 additions and 2 deletions
17
.github/workflows/ci.yml
vendored
17
.github/workflows/ci.yml
vendored
|
|
@ -59,3 +59,20 @@ jobs:
|
||||||
# Exit-zero treats all errors as warnings
|
# Exit-zero treats all errors as warnings
|
||||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
|
rust-checks:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Rust
|
||||||
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
|
||||||
|
- name: Check formatting
|
||||||
|
run: cargo fmt --all -- --check
|
||||||
|
|
||||||
|
- name: Run clippy
|
||||||
|
run: cargo clippy -- -D warnings
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: cargo test
|
||||||
|
|
|
||||||
|
|
@ -16,3 +16,9 @@ log = "0.4"
|
||||||
env_logger = "0.11"
|
env_logger = "0.11"
|
||||||
csv = "1.3"
|
csv = "1.3"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
lto = true
|
||||||
|
codegen-units = 1
|
||||||
|
strip = true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ pub struct AlertSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct Alert {
|
pub struct Alert {
|
||||||
pub alert_type: String,
|
pub alert_type: String,
|
||||||
pub message: String,
|
pub message: String,
|
||||||
|
|
@ -62,6 +63,7 @@ impl AlertSystem {
|
||||||
println!("\n⚠️ ALERT: {}", message);
|
println!("\n⚠️ ALERT: {}", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn get_alert_history(&self) -> &[Alert] {
|
pub fn get_alert_history(&self) -> &[Alert] {
|
||||||
&self.alert_history
|
&self.alert_history
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![allow(dead_code)]
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ impl TrackerLogger {
|
||||||
self.write_log("WARNING", &alert_message);
|
self.write_log("WARNING", &alert_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn log_error(&self, error_message: &str) {
|
pub fn log_error(&self, error_message: &str) {
|
||||||
let error_msg = format!("ERROR: {}", error_message);
|
let error_msg = format!("ERROR: {}", error_message);
|
||||||
self.write_log("ERROR", &error_msg);
|
self.write_log("ERROR", &error_msg);
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,6 @@ impl SystemMonitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_cpu_usage(&mut self) -> f32 {
|
pub fn get_cpu_usage(&mut self) -> f32 {
|
||||||
self.sys.refresh_cpu_all();
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(200));
|
|
||||||
self.sys.refresh_cpu_all();
|
self.sys.refresh_cpu_all();
|
||||||
self.sys.global_cpu_usage()
|
self.sys.global_cpu_usage()
|
||||||
}
|
}
|
||||||
|
|
@ -163,6 +161,7 @@ impl SystemMonitor {
|
||||||
pub struct MemoryInfo {
|
pub struct MemoryInfo {
|
||||||
pub total: u64,
|
pub total: u64,
|
||||||
pub used: u64,
|
pub used: u64,
|
||||||
|
#[allow(dead_code)]
|
||||||
pub available: u64,
|
pub available: u64,
|
||||||
pub percent: f32,
|
pub percent: f32,
|
||||||
}
|
}
|
||||||
|
|
@ -171,6 +170,7 @@ pub struct MemoryInfo {
|
||||||
pub struct DiskInfo {
|
pub struct DiskInfo {
|
||||||
pub total: u64,
|
pub total: u64,
|
||||||
pub used: u64,
|
pub used: u64,
|
||||||
|
#[allow(dead_code)]
|
||||||
pub free: u64,
|
pub free: u64,
|
||||||
pub percent: f32,
|
pub percent: f32,
|
||||||
}
|
}
|
||||||
|
|
@ -179,6 +179,8 @@ pub struct DiskInfo {
|
||||||
pub struct NetworkStats {
|
pub struct NetworkStats {
|
||||||
pub bytes_sent: u64,
|
pub bytes_sent: u64,
|
||||||
pub bytes_recv: u64,
|
pub bytes_recv: u64,
|
||||||
|
#[allow(dead_code)]
|
||||||
pub packets_sent: u64,
|
pub packets_sent: u64,
|
||||||
|
#[allow(dead_code)]
|
||||||
pub packets_recv: u64,
|
pub packets_recv: u64,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue