]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: provide method to get half-life
authorPatrick Donnelly <pdonnell@redhat.com>
Fri, 2 Aug 2019 20:10:52 +0000 (13:10 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 13 Sep 2019 00:42:02 +0000 (17:42 -0700)
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 <pdonnell@redhat.com>
src/common/DecayCounter.cc
src/common/DecayCounter.h

index 9dd491188e30501ec10c11fe9d860c20917f52b7..f34a6eba386e96624b3a3d0b54eb7390cd26743d 100644 (file)
@@ -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<DecayCounter*>& ls)
index b9cbef429072696a9221893a5d35fc86817e1ee9..b9545b1516194d118d10023f24605fbb11a9cf0a 100644 (file)
@@ -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