diff options
Diffstat (limited to 'tests/framework/instruments')
-rw-r--r-- | tests/framework/instruments/Measurement.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/framework/instruments/Measurement.h b/tests/framework/instruments/Measurement.h index 8a1ec9cb14..9fb75d7b99 100644 --- a/tests/framework/instruments/Measurement.h +++ b/tests/framework/instruments/Measurement.h @@ -92,6 +92,44 @@ struct Measurement return b; } + /** Subtract with another value and return the result + * + * @param[in] b Other value + * + * @return Result of the stored value - b + */ + Value operator-(Value b) const + { + if(is_floating_point) + { + b.v.floating_point -= v.floating_point; + } + else + { + b.v.integer -= v.integer; + } + return b; + } + + /** Multiple with another value and return the result + * + * @param[in] b Other value + * + * @return Result of the stored value * b + */ + Value operator*(Value b) const + { + if(is_floating_point) + { + b.v.floating_point *= v.floating_point; + } + else + { + b.v.integer *= v.integer; + } + return b; + } + /** Return the stored value divided by an integer. * * @param[in] b Integer to divide the value by. @@ -149,6 +187,18 @@ struct Measurement } } + static double relative_standard_deviation(const Value &variance, const Value &mean) + { + if(variance.is_floating_point) + { + return 100.0 * sqrt(variance.v.floating_point) / mean.v.floating_point; + } + else + { + return 100.0 * sqrt(static_cast<double>(variance.v.integer)) / mean.v.integer; + } + } + /** Stored value */ union { |