|
Peano
|
Measurement. More...
#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 |
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.
Definition at line 29 of file Measurement.h.
| tarch::timing::Measurement::Measurement | ( | const double & | accuracy = 0.0 | ) |
|
default |
| void tarch::timing::Measurement::erase | ( | ) |
| double tarch::timing::Measurement::getAccumulatedValue | ( | ) | const |
| double tarch::timing::Measurement::getAccuracy | ( | ) | const |
|
private |
|
private |
| double tarch::timing::Measurement::getMostRecentValue | ( | ) | const |
| int tarch::timing::Measurement::getNumberOfMeasurements | ( | ) | const |
| 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.
| double tarch::timing::Measurement::getValue | ( | ) | const |
| void tarch::timing::Measurement::increaseAccuracy | ( | const double & | factor | ) |
| 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.
| double tarch::timing::Measurement::max | ( | ) | const |
| double tarch::timing::Measurement::min | ( | ) | const |
| 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.
| std::string tarch::timing::Measurement::toString | ( | ) | const |
|
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.