pub fn prep_meter(&self,
                      meters: &HashMap<String, Box<dyn EnergyMetering>>,
                      out: &mut HashMap<String, Vec<(Instant, f32)>>,
    ) -> Result<bool> {
        // only care about meters defined in the criteria
        out.clear();

        let approx_loop_micros = 545;
        let max_sample_count = (self.max_runtime().as_micros() /
                                approx_loop_micros as u128) + 1;

        let mut has_energy_criteria = false;
        // pre-allocate space in sample output vectors
        for criterion in &self.criteria {
            if let Criterion::Energy(ref energy_criterion) = criterion {
                has_energy_criteria = true;
                let meter_id = energy_criterion.get_meter();
                if !meters.contains_key(meter_id) {
                    return Err(TestingError::NoSuchMeter(meter_id.to_string()));
                } else {
                    out.entry(meter_id.to_string())
                        .or_insert(Vec::new())
                        .reserve_exact(max_sample_count as usize);
                }
            }
        }

        Ok(has_energy_criteria)
    }
/// Prepare structures for energy metering.
///
/// # Returns
/// Returns true if there are energy metering criteria in this test.
/// [`Test::meter`] should be called when running the test.
Prepare structures for energy metering.
Prepare structures for energy metering .
pub fn prep_meter(&self,
                      meters: &HashMap<String, Box<dyn EnergyMetering>>,
                      out: &mut HashMap<String, Vec<(Instant, f32)>>,
    ) -> Result<bool> {
        // only care about meters defined in the criteria
        out.clear();
        let approx_loop_micros = 545;
        let max_sample_count = (self.max_runtime().as_micros() /
                                approx_loop_micros as u128) + 1;
        let mut has_energy_criteria = false;
        // pre-allocate space in sample output vectors
        for criterion in &self.criteria {
            if let Criterion::Energy(ref energy_criterion) = criterion {
                has_energy_criteria = true;
                let meter_id = energy_criterion.get_meter();
                if !meters.contains_key(meter_id) {
                    return Err(TestingError::NoSuchMeter(meter_id.to_string()));
                } else {
                    out.entry(meter_id.to_string())
                        .or_insert(Vec::new())
                        .reserve_exact(max_sample_count as usize);
                }
            }
        }
        Ok(has_energy_criteria)
    }
pub fn prep_meter ( & self , meters : & HashMap < String , Box < dyn EnergyMetering > > , out : & mut HashMap < String , Vec < ( Instant , f32 ) > > , ) -> Result < bool > { // only care about meters defined in the criteria out . clear ( ) ; let approx_loop_micros = 545 ; let max_sample_count = ( self . max_runtime ( ) . as_micros ( ) / approx_loop_micros as u128 ) + 1 ; let mut has_energy_criteria = false ; // pre-allocate space in sample output vectors for criterion in & self . criteria { if let Criterion :: Energy ( ref energy_criterion ) = criterion { has_energy_criteria = true ; let meter_id = energy_criterion . get_meter ( ) ; if ! meters . contains_key ( meter_id ) { return Err ( TestingError :: NoSuchMeter ( meter_id . to_string ( ) ) ) ; } else { out . entry ( meter_id . to_string ( ) ) . or_insert ( Vec :: new ( ) ) . reserve_exact ( max_sample_count as usize ) ; } } } Ok ( has_energy_criteria ) }
Prepare structures for energy metering.
Prepare structures for energy metering .
&self
meters
&HashMap<String, Box<dyn EnergyMetering>>
out
&mut HashMap<String, Vec<(Instant, f32)>>
Returns true if there are energy metering criteria in this test.
[`Test::meter`] should be called when running the test.
Returns true if there are energy metering criteria in this test . [ ` Test :: meter ` ] should be called when running the test .
&self
meters
&HashMap<String, Box<dyn EnergyMetering>>
out
&mut HashMap<String, Vec<(Instant, f32)>>