Peano 4

#include <Measurement.h>
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 
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.
Definition at line 29 of file Measurement.h.
tarch::timing::Measurement::Measurement  (  const double &  accuracy = 0.0  ) 
Definition at line 18 of file Measurement.cpp.
References assertion1.

default 
void tarch::timing::Measurement::erase  (  ) 
Definition at line 34 of file Measurement.cpp.
Referenced by runBenchmarks().
double tarch::timing::Measurement::getAccumulatedValue  (  )  const 
Definition at line 58 of file Measurement.cpp.
Referenced by main().
double tarch::timing::Measurement::getAccuracy  (  )  const 
Definition at line 186 of file Measurement.cpp.

private 
Definition at line 46 of file Measurement.cpp.
References assertion.

private 
Definition at line 52 of file Measurement.cpp.
References assertion.
double tarch::timing::Measurement::getMostRecentValue  (  )  const 
Definition at line 61 of file Measurement.cpp.
int tarch::timing::Measurement::getNumberOfMeasurements  (  )  const 
Definition at line 136 of file Measurement.cpp.
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 roundoff error. We circumnavigate it by adding an absolute value which is mathematically not required.
Definition at line 76 of file Measurement.cpp.
References assertionEquals, and tarch::la::smaller().
double tarch::timing::Measurement::getValue  (  )  const 
Definition at line 66 of file Measurement.cpp.
References assertionEquals, and tarch::la::smaller().
Referenced by main(), and reportRuntime().
void tarch::timing::Measurement::increaseAccuracy  (  const double &  factor  ) 
Definition at line 95 of file Measurement.cpp.
References assertion.
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.
double tarch::timing::Measurement::max  (  )  const 
Definition at line 174 of file Measurement.cpp.
References assertion1, and tarch::toString().
double tarch::timing::Measurement::min  (  )  const 
Definition at line 180 of file Measurement.cpp.
References assertion1, and tarch::toString().
void tarch::timing::Measurement::setAccuracy  (  const double &  value  ) 
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 assertion, logDebug, and tarch::la::smallerEquals().
Referenced by main(), runBenchmarks(), and step().
std::string tarch::timing::Measurement::toString  (  )  const 
Definition at line 139 of file Measurement.cpp.
Referenced by main(), and reportRuntime().

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.

private 
Accumulated value.
The sum of all values divided by _numberOfMeasurements gives the mean value.
Definition at line 41 of file Measurement.h.

private 
Definition at line 33 of file Measurement.h.

private 
Definition at line 61 of file Measurement.h.

private 
We store the last value.
Definition at line 46 of file Measurement.h.

staticprivate 
Definition at line 31 of file Measurement.h.

private 
Definition at line 63 of file Measurement.h.

private 
Definition at line 65 of file Measurement.h.

private 
Definition at line 62 of file Measurement.h.

private 
Definition at line 64 of file Measurement.h.

private 
Needed to compute average value and variance.
Definition at line 60 of file Measurement.h.