#[cfg(target_os = "linux")]
use crate::dtos::cpu::CpuInfo;

use sysinfo::{CpuRefreshKind, RefreshKind, System};

#[cfg(target_os = "linux")]
pub fn get_cpu_info() -> CpuInfo {
    let s = System::new_with_specifics(RefreshKind::new().with_cpu(CpuRefreshKind::everything()));
    let proc = s.cpus().first().unwrap();

    CpuInfo {
        name: proc.brand().trim().to_string(),
        identifier: format!("{} - {}", proc.vendor_id(), proc.name()),
        processor_id: None,
        vendor_frequency: (1000000 * proc.frequency()),
        physical_processor_count: num_cpus::get_physical(),
    }
}
