Peano
Loading...
Searching...
No Matches
tarch::timing::Measurement Class Reference

Measurement. More...

#include <Measurement.h>

Collaboration diagram for tarch::timing::Measurement:

Public Member Functions

 Measurement (const double &accuracy=0.0)
 
 ~Measurement ()=default
 
double getValue () const
 
double getMostRecentValue () const
 
double getAccumulatedValue () const
 
double getStandardDeviation () const
 We did face some seg faults (very rarely) where the parameter under the square root did become slightly negative.
 
bool isAccurateValue () const
 Is value accurate.
 
void setAccuracy (const double &value)
 
void increaseAccuracy (const double &factor)
 
void setValue (const double &value)
 Set the value.
 
int getNumberOfMeasurements () const
 
std::string toString () const
 
double max () const
 
double min () const
 
void erase ()
 
double getAccuracy () const
 

Private Member Functions

double getMeanValue () const
 
double getMeanValueOfNextStep (double newValue) const
 

Private Attributes

double _accuracy
 
double _accumulatedValue
 Accumulated value.
 
double _lastValue
 We store the last value.
 
double _accumulatedSquares
 To compute the standard deviation, we rely on the formula.
 
double _numberOfMeasurements
 Needed to compute average value and variance.
 
bool _isAccurateValue
 
double _min
 
double _max
 
double _minMeasurement
 
double _maxMeasurement
 

Static Private Attributes

static tarch::logging::Log _log
 

Detailed Description

Measurement.

The shared memory oracles have to handle real time measurements. This data is always noisy, inaccurate, and has to be averaged. We originally planned to move all the averaging etc. to the oracle singleton. However, that is hardly possible, as the responsible oracle changes all the time, and the measurements are associated to one oracle. Consequently, we introduced this helper class for the individual oracle implementations.

Author
Tobias Weinzierl

Definition at line 29 of file Measurement.h.

Constructor & Destructor Documentation

◆ Measurement()

tarch::timing::Measurement::Measurement ( const double & accuracy = 0.0)

◆ ~Measurement()

tarch::timing::Measurement::~Measurement ( )
default

Member Function Documentation

◆ erase()

void tarch::timing::Measurement::erase ( )

◆ getAccumulatedValue()

double tarch::timing::Measurement::getAccumulatedValue ( ) const
Returns
Sum over all values measured so far.

◆ getAccuracy()

double tarch::timing::Measurement::getAccuracy ( ) const

◆ getMeanValue()

double tarch::timing::Measurement::getMeanValue ( ) const
private

◆ getMeanValueOfNextStep()

double tarch::timing::Measurement::getMeanValueOfNextStep ( double newValue) const
private

◆ getMostRecentValue()

double tarch::timing::Measurement::getMostRecentValue ( ) const
Returns
Last value added. If there's none so far, the routine returns 0. If you've only added one value so far, the result equals getValue().

◆ getNumberOfMeasurements()

int tarch::timing::Measurement::getNumberOfMeasurements ( ) const

◆ getStandardDeviation()

double tarch::timing::Measurement::getStandardDeviation ( ) const

We did face some seg faults (very rarely) where the parameter under the square root did become slightly negative.

This seems to be a round-off error. We circumnavigate it by adding an absolute value which is mathematically not required.

◆ getValue()

double tarch::timing::Measurement::getValue ( ) const
Returns
Averaged value (mean value) of all measurements. If you have not yet added a value, it returns 0.

◆ increaseAccuracy()

void tarch::timing::Measurement::increaseAccuracy ( const double & factor)

◆ isAccurateValue()

bool tarch::timing::Measurement::isAccurateValue ( ) const

Is value accurate.

Whether a value is accurate depends on the last setValue() call. The class internally holds the mean value of all setValue() calls. If a new value is set/added, the object checks whether this additional measurement modifies the mean value more than the given accuracy. If this is the case, the object does not represent a valid measurement yet.

It does not work if we just compare new values to the mean value. If a measurement looks similar to the sketch from above (black=mean value, grey area=accuracy, blue points=values), the measurement never would become valid.

I therefore use a normalised mean value

\( valid = | \frac{ m^{(n+1)} - m^{(n)} }{m^{(n)}} | \leq \epsilon = | \frac{m^{(n+1)}}{m^{(n)}}-1 | \leq \epsilon \)

where \( m^{(n)} \) and \( m^{(n+1)} \) are two subsequent mean values.

◆ max()

double tarch::timing::Measurement::max ( ) const

◆ min()

double tarch::timing::Measurement::min ( ) const

◆ setAccuracy()

void tarch::timing::Measurement::setAccuracy ( const double & value)
See also
isAccurateValue()

◆ setValue()

void tarch::timing::Measurement::setValue ( const double & value)

Set the value.

If the measurement already holds a value, this value is not overwritten. Instead, the measurement accumulates all values and returns the average.

◆ toString()

std::string tarch::timing::Measurement::toString ( ) const

Field Documentation

◆ _accumulatedSquares

double tarch::timing::Measurement::_accumulatedSquares
private

To compute the standard deviation, we rely on the formula.

sigma = sqrt(E(x^2) - E(x)^2)

with E being the mean value.

Definition at line 55 of file Measurement.h.

◆ _accumulatedValue

double tarch::timing::Measurement::_accumulatedValue
private

Accumulated value.

The sum of all values divided by _numberOfMeasurements gives the mean value.

Definition at line 41 of file Measurement.h.

◆ _accuracy

double tarch::timing::Measurement::_accuracy
private

Definition at line 33 of file Measurement.h.

◆ _isAccurateValue

bool tarch::timing::Measurement::_isAccurateValue
private

Definition at line 61 of file Measurement.h.

◆ _lastValue

double tarch::timing::Measurement::_lastValue
private

We store the last value.

Definition at line 46 of file Measurement.h.

◆ _log

tarch::logging::Log tarch::timing::Measurement::_log
staticprivate

Definition at line 31 of file Measurement.h.

◆ _max

double tarch::timing::Measurement::_max
private

Definition at line 63 of file Measurement.h.

◆ _maxMeasurement

double tarch::timing::Measurement::_maxMeasurement
private

Definition at line 65 of file Measurement.h.

◆ _min

double tarch::timing::Measurement::_min
private

Definition at line 62 of file Measurement.h.

◆ _minMeasurement

double tarch::timing::Measurement::_minMeasurement
private

Definition at line 64 of file Measurement.h.

◆ _numberOfMeasurements

double tarch::timing::Measurement::_numberOfMeasurements
private

Needed to compute average value and variance.

Definition at line 60 of file Measurement.h.


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