Compute Library
 21.05
Measurement Struct Reference

Generic measurement that stores values as either double or long long int. More...

#include <Measurement.h>

Data Structures

struct  Value
 Measurement value. More...
 

Public Member Functions

bool operator< (const Measurement &b) const
 Compare the stored value with another value. More...
 
template<typename Floating , typename std::enable_if< !std::is_integral< Floating >::value, int >::type = 0>
 Measurement (Floating v, std::string unit, std::list< std::string > raw={})
 Constructor to store a floating point value. More...
 
template<typename Integer , typename std::enable_if< std::is_integral< Integer >::value, int >::type = 0>
 Measurement (Integer v, std::string unit, std::list< std::string > raw={})
 Constructor to store an integer value. More...
 
const std::string & unit () const
 Accessor for the unit of the measurement. More...
 
const std::list< std::string > & raw_data () const
 Accessor for the raw data. More...
 
const Valuevalue () const
 Accessor for the stored value. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Measurement &measurement)
 Stream output operator to print the measurement. More...
 

Detailed Description

Generic measurement that stores values as either double or long long int.

Definition at line 41 of file Measurement.h.

Constructor & Destructor Documentation

◆ Measurement() [1/2]

Measurement ( Floating  v,
std::string  unit,
std::list< std::string >  raw = {} 
)
inline

Constructor to store a floating point value.

Parameters
[in]vValue to store
[in]unitUnit of v
[in]raw(Optional) The raw value(s) was generated from.

Definition at line 252 of file Measurement.h.

252  {})
253  : _unit(unit), _raw_data(std::move(raw)), _value(true)
254  {
255  _value.v.floating_point = static_cast<double>(v);
256  if(_raw_data.empty())
257  {
258  _raw_data = { _value.to_string() };
259  }
260  }
std::string to_string() const
Convert the value stored to string.
Definition: Measurement.h:71
union arm_compute::test::framework::Measurement::Value::@5 v
Stored value.
const std::string & unit() const
Accessor for the unit of the measurement.
Definition: Measurement.h:283

◆ Measurement() [2/2]

Measurement ( Integer  v,
std::string  unit,
std::list< std::string >  raw = {} 
)
inline

Constructor to store an integer value.

Parameters
[in]vValue to store
[in]unitUnit of v
[in]raw(Optional) The raw value(s) was generated from.

Definition at line 269 of file Measurement.h.

269  {})
270  : _unit(unit), _raw_data(std::move(raw)), _value(false)
271  {
272  _value.v.integer = static_cast<long long int>(v);
273  if(_raw_data.empty())
274  {
275  _raw_data = { _value.to_string() };
276  }
277  }
std::string to_string() const
Convert the value stored to string.
Definition: Measurement.h:71
union arm_compute::test::framework::Measurement::Value::@5 v
Stored value.
const std::string & unit() const
Accessor for the unit of the measurement.
Definition: Measurement.h:283

Member Function Documentation

◆ operator<()

bool operator< ( const Measurement b) const
inline

Compare the stored value with another value.

Parameters
[in]bValue to compare against
Returns
The result of stored value < b

Definition at line 225 of file Measurement.h.

226  {
227  return _value < b.value();
228  }
SimpleTensor< float > b
Definition: DFT.cpp:157

References arm_compute::test::validation::b.

◆ raw_data()

const std::list<std::string>& raw_data ( ) const
inline

Accessor for the raw data.

Returns
The raw data

Definition at line 292 of file Measurement.h.

293  {
294  return _raw_data;
295  }

◆ unit()

const std::string& unit ( ) const
inline

Accessor for the unit of the measurement.

Returns
Unit of the measurement

Definition at line 283 of file Measurement.h.

284  {
285  return _unit;
286  }

Referenced by PrettyPrinter::print_measurements().

◆ value()

const Value& value ( ) const
inline

Accessor for the stored value.

Returns
The stored value

Definition at line 301 of file Measurement.h.

302  {
303  return _value;
304  }

Referenced by InstrumentsStats::InstrumentsStats(), and PrettyPrinter::print_measurements().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Measurement measurement 
)
friend

Stream output operator to print the measurement.

Prints value and unit.

Parameters
[out]osOutput stream.
[in]measurementMeasurement.
Returns
the modified output stream.

Definition at line 239 of file Measurement.h.

240  {
241  os << measurement._value << " " << measurement._unit;
242  return os;
243  }

The documentation for this struct was generated from the following file: