From 91fed04c496d50ded703a033fae539974e6dc3b5 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Fri, 2 Aug 2019 13:10:52 -0700 Subject: [PATCH] common: provide method to get half-life Print the half-life in Formatter output as it is human understandable and the value used when configuring the counters. Signed-off-by: Patrick Donnelly --- src/common/DecayCounter.cc | 2 +- src/common/DecayCounter.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/DecayCounter.cc b/src/common/DecayCounter.cc index 9dd491188e3..f34a6eba386 100644 --- a/src/common/DecayCounter.cc +++ b/src/common/DecayCounter.cc @@ -51,7 +51,7 @@ void DecayCounter::dump(Formatter *f) const { decay(); f->dump_float("value", val); - f->dump_float("halflife", rate.k); + f->dump_float("halflife", rate.get_halflife()); } void DecayCounter::generate_test_instances(std::list& ls) diff --git a/src/common/DecayCounter.h b/src/common/DecayCounter.h index b9cbef42907..b9545b15161 100644 --- a/src/common/DecayCounter.h +++ b/src/common/DecayCounter.h @@ -44,6 +44,9 @@ public: void set_halflife(double hl) { k = log(.5) / hl; } + double get_halflife() const { + return log(.5) / k; + } private: double k = 0; // k = ln(.5)/half_life -- 2.39.5