//! CPU topology detection

use super::super::error::ProfilingError;

/// CPU topology information
#[derive(Debug, Clone)]
pub struct CpuTopology {
    pub cores: u32,
    pub threads: u32,
    pub sockets: u32,
}

/// Detect CPU topology (cores, threads, sockets)
pub fn detect_cpu_topology() -> Result<CpuTopology, ProfilingError> {
    // Use num_cpus crate for cross-platform CPU detection
    let threads = num_cpus::get() as u32;
    let cores = num_cpus::get_physical() as u32;

    // Estimate sockets based on thread-to-core ratio
    let sockets = if threads > cores { 2 } else { 1 };

    Ok(CpuTopology {
        cores,
        threads,
        sockets,
    })
}
