use indexmap::IndexMap;
use rapl_energy::Rapl;
use std::sync::{Arc, Mutex};

use super::Probe;

impl Probe for Rapl {
    fn elapsed(&self) -> IndexMap<String, f32> {
        Rapl::elapsed(&self)
    }

    fn reset(&mut self) {
        Rapl::reset(self);
    }
}

pub fn rapl() -> Option<Arc<Mutex<dyn Probe>>> {
    Rapl::now(true).map(|x| Arc::new(Mutex::new(x)) as Arc<Mutex<dyn Probe>>)
}
