From: Patrick Donnelly Date: Fri, 2 Aug 2019 20:10:52 +0000 (-0700) Subject: common: provide method to get half-life X-Git-Tag: v15.1.0~1563^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=91fed04c496d50ded703a033fae539974e6dc3b5;p=ceph.git 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 --- diff --git a/src/common/DecayCounter.cc b/src/common/DecayCounter.cc index 9dd491188e30..f34a6eba386e 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 b9cbef429072..b9545b151619 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