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
|
||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||
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"
|
||||
csv = "1.3"
|
||||
anyhow = "1.0"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
strip = true
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ pub struct AlertSystem {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct Alert {
|
||||
pub alert_type: String,
|
||||
pub message: String,
|
||||
|
|
@ -62,6 +63,7 @@ impl AlertSystem {
|
|||
println!("\n⚠️ ALERT: {}", message);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_alert_history(&self) -> &[Alert] {
|
||||
&self.alert_history
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#![allow(dead_code)]
|
||||
use serde::Serialize;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ impl TrackerLogger {
|
|||
self.write_log("WARNING", &alert_message);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn log_error(&self, error_message: &str) {
|
||||
let error_msg = format!("ERROR: {}", error_message);
|
||||
self.write_log("ERROR", &error_msg);
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ impl SystemMonitor {
|
|||
}
|
||||
|
||||
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.global_cpu_usage()
|
||||
}
|
||||
|
|
@ -163,6 +161,7 @@ impl SystemMonitor {
|
|||
pub struct MemoryInfo {
|
||||
pub total: u64,
|
||||
pub used: u64,
|
||||
#[allow(dead_code)]
|
||||
pub available: u64,
|
||||
pub percent: f32,
|
||||
}
|
||||
|
|
@ -171,6 +170,7 @@ pub struct MemoryInfo {
|
|||
pub struct DiskInfo {
|
||||
pub total: u64,
|
||||
pub used: u64,
|
||||
#[allow(dead_code)]
|
||||
pub free: u64,
|
||||
pub percent: f32,
|
||||
}
|
||||
|
|
@ -179,6 +179,8 @@ pub struct DiskInfo {
|
|||
pub struct NetworkStats {
|
||||
pub bytes_sent: u64,
|
||||
pub bytes_recv: u64,
|
||||
#[allow(dead_code)]
|
||||
pub packets_sent: u64,
|
||||
#[allow(dead_code)]
|
||||
pub packets_recv: u64,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue