|
Peano
|
#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 _accumulatedSquares, _accumulatedValue, _accuracy, _isAccurateValue, _lastValue, _max, _maxMeasurement, _min, _minMeasurement, _numberOfMeasurements, assertion1, double, and max().

|
default |
| void tarch::timing::Measurement::erase | ( | ) |
Definition at line 34 of file Measurement.cpp.
References _accumulatedSquares, _accumulatedValue, _isAccurateValue, _max, _maxMeasurement, _min, _minMeasurement, and _numberOfMeasurements.
| double tarch::timing::Measurement::getAccumulatedValue | ( | ) | const |
Definition at line 58 of file Measurement.cpp.
References _accumulatedValue.
| double tarch::timing::Measurement::getAccuracy | ( | ) | const |
Definition at line 186 of file Measurement.cpp.
References _accuracy.
|
private |
Definition at line 46 of file Measurement.cpp.
References _accumulatedValue, _numberOfMeasurements, and assertion.
Referenced by getStandardDeviation(), getValue(), and setValue().

Definition at line 52 of file Measurement.cpp.
References _accumulatedValue, _numberOfMeasurements, and assertion.
Referenced by setValue().

| double tarch::timing::Measurement::getMostRecentValue | ( | ) | const |
Definition at line 61 of file Measurement.cpp.
References _lastValue.
| int tarch::timing::Measurement::getNumberOfMeasurements | ( | ) | const |
Definition at line 136 of file Measurement.cpp.
References _numberOfMeasurements.
| 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 _accumulatedSquares, _accumulatedValue, _numberOfMeasurements, std::abs(), assertionEquals, and getMeanValue().
Referenced by toString().


| double tarch::timing::Measurement::getValue | ( | ) | const |
Definition at line 66 of file Measurement.cpp.
References _accumulatedValue, _numberOfMeasurements, assertionEquals, and getMeanValue().
Referenced by assessKernel(), reportRuntime(), reportRuntime(), and toString().


Definition at line 95 of file Measurement.cpp.
| 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.
References _isAccurateValue.
Referenced by max(), and min().

| double tarch::timing::Measurement::max | ( | ) | const |
Definition at line 174 of file Measurement.cpp.
References _max, assertion1, isAccurateValue(), and tarch::toString().
Referenced by Measurement().


| double tarch::timing::Measurement::min | ( | ) | const |
Definition at line 180 of file Measurement.cpp.
References _min, assertion1, isAccurateValue(), and tarch::toString().

Definition at line 89 of file Measurement.cpp.
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 _accumulatedSquares, _accumulatedValue, _accuracy, _isAccurateValue, _lastValue, _max, _maxMeasurement, _min, _minMeasurement, _numberOfMeasurements, std::abs(), assertion, getMeanValue(), getMeanValueOfNextStep(), and logDebug.
Referenced by assessKernel(), runBenchmarks(), and runBenchmarks().


| std::string tarch::timing::Measurement::toString | ( | ) | const |
Definition at line 139 of file Measurement.cpp.
References _accuracy, _isAccurateValue, _max, _maxMeasurement, _min, _minMeasurement, _numberOfMeasurements, getStandardDeviation(), and getValue().
Referenced by assessKernel(), reportRuntime(), 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.
Referenced by erase(), getStandardDeviation(), Measurement(), and setValue().
|
private |
Accumulated value.
The sum of all values divided by _numberOfMeasurements gives the mean value.
Definition at line 41 of file Measurement.h.
Referenced by erase(), getAccumulatedValue(), getMeanValue(), getMeanValueOfNextStep(), getStandardDeviation(), getValue(), Measurement(), and setValue().
|
private |
Definition at line 33 of file Measurement.h.
Referenced by getAccuracy(), increaseAccuracy(), Measurement(), setAccuracy(), setValue(), and toString().
|
private |
Definition at line 61 of file Measurement.h.
Referenced by erase(), isAccurateValue(), Measurement(), setValue(), and toString().
|
private |
We store the last value.
Definition at line 46 of file Measurement.h.
Referenced by getMostRecentValue(), Measurement(), and setValue().
|
staticprivate |
Definition at line 31 of file Measurement.h.
|
private |
Definition at line 63 of file Measurement.h.
Referenced by erase(), max(), Measurement(), setValue(), and toString().
|
private |
Definition at line 65 of file Measurement.h.
Referenced by erase(), Measurement(), setValue(), and toString().
|
private |
Definition at line 62 of file Measurement.h.
Referenced by erase(), Measurement(), min(), setValue(), and toString().
|
private |
Definition at line 64 of file Measurement.h.
Referenced by erase(), Measurement(), setValue(), and toString().
|
private |
Needed to compute average value and variance.
Definition at line 60 of file Measurement.h.
Referenced by erase(), getMeanValue(), getMeanValueOfNextStep(), getNumberOfMeasurements(), getStandardDeviation(), getValue(), Measurement(), setValue(), and toString().