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)

Definition at line 18 of file Measurement.cpp.

References assertion1.

◆ ~Measurement()

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

Member Function Documentation

◆ erase()

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

Definition at line 34 of file Measurement.cpp.

Referenced by runBenchmarks(), and runBenchmarks().

Here is the caller graph for this function:

◆ getAccumulatedValue()

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

Definition at line 58 of file Measurement.cpp.

Referenced by main().

Here is the caller graph for this function:

◆ getAccuracy()

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

Definition at line 186 of file Measurement.cpp.

◆ getMeanValue()

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

Definition at line 46 of file Measurement.cpp.

References assertion.

◆ getMeanValueOfNextStep()

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

Definition at line 52 of file Measurement.cpp.

References assertion.

◆ 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().

Definition at line 61 of file Measurement.cpp.

◆ getNumberOfMeasurements()

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

Definition at line 136 of file Measurement.cpp.

◆ 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.

Definition at line 76 of file Measurement.cpp.

References std::abs(), assertionEquals, and tarch::la::smaller().

Here is the call graph for this function:

◆ 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.

Definition at line 66 of file Measurement.cpp.

References assertionEquals, and tarch::la::smaller().

Referenced by assessKernel(), main(), reportRuntime(), reportRuntime(), and reportRuntime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ increaseAccuracy()

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

Definition at line 95 of file Measurement.cpp.

References assertion.

◆ 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.

Definition at line 86 of file Measurement.cpp.

◆ max()

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

Definition at line 174 of file Measurement.cpp.

References assertion1, and tarch::toString().

Here is the call graph for this function:

◆ min()

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

Definition at line 180 of file Measurement.cpp.

References assertion1, and tarch::toString().

Here is the call graph for this function:

◆ setAccuracy()

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

Definition at line 89 of file Measurement.cpp.

References assertion.

◆ 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.

Definition at line 101 of file Measurement.cpp.

References std::abs(), assertion, logDebug, and tarch::la::smallerEquals().

Referenced by assessKernel(), main(), runBenchmarks(), runBenchmarks(), and step().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toString()

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

Definition at line 139 of file Measurement.cpp.

Referenced by assessKernel(), main(), reportRuntime(), reportRuntime(), and reportRuntime().

Here is the caller graph for this function:

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 files: