]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
perfcounters: Allow C++11 time increment/decrement
authorAdam C. Emerson <aemerson@redhat.com>
Mon, 14 Sep 2015 16:19:35 +0000 (12:19 -0400)
committerSage Weil <sage@redhat.com>
Fri, 18 Dec 2015 20:15:04 +0000 (15:15 -0500)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/common/perf_counters.cc
src/common/perf_counters.h

index 0c86f130b5a29495ab95d928b6ac8668f6ed1fad..757ad4ebb363d871a15ff9a8b3c84b8247346b6c 100644 (file)
@@ -221,6 +221,25 @@ void PerfCounters::tinc(int idx, utime_t amt)
   }
 }
 
+void PerfCounters::tinc(int idx, ceph::timespan amt)
+{
+  if (!m_cct->_conf->perf)
+    return;
+
+  assert(idx > m_lower_bound);
+  assert(idx < m_upper_bound);
+  perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]);
+  if (!(data.type & PERFCOUNTER_TIME))
+    return;
+  if (data.type & PERFCOUNTER_LONGRUNAVG) {
+    data.avgcount.inc();
+    data.u64.add(amt.count());
+    data.avgcount2.inc();
+  } else {
+    data.u64.add(amt.count());
+  }
+}
+
 void PerfCounters::tset(int idx, utime_t amt)
 {
   if (!m_cct->_conf->perf)
index 74dfa7dab73149189f084c8051b81a382991ac6c..5a462f968d436f1252ecf1375aacee13fb70cfa9 100644 (file)
 #include "common/Mutex.h"
 #include "include/utime.h"
 
+#include "common/config_obs.h"
+#include "common/Mutex.h"
+#include "common/ceph_time.h"
+
 #include <stdint.h>
 #include <string>
 #include <vector>
@@ -91,6 +95,7 @@ public:
 
   void tset(int idx, utime_t v);
   void tinc(int idx, utime_t v);
+  void tinc(int idx, ceph::timespan v);
   utime_t tget(int idx) const;
 
   void reset();