From: Adam C. Emerson Date: Mon, 14 Sep 2015 16:19:35 +0000 (-0400) Subject: perfcounters: Allow C++11 time increment/decrement X-Git-Tag: v10.0.3~194^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4367eb18d290e6b640726714bebc1f34e8477c0a;p=ceph.git perfcounters: Allow C++11 time increment/decrement Signed-off-by: Adam C. Emerson --- diff --git a/src/common/perf_counters.cc b/src/common/perf_counters.cc index 0c86f130b5a..757ad4ebb36 100644 --- a/src/common/perf_counters.cc +++ b/src/common/perf_counters.cc @@ -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) diff --git a/src/common/perf_counters.h b/src/common/perf_counters.h index 74dfa7dab73..5a462f968d4 100644 --- a/src/common/perf_counters.h +++ b/src/common/perf_counters.h @@ -20,6 +20,10 @@ #include "common/Mutex.h" #include "include/utime.h" +#include "common/config_obs.h" +#include "common/Mutex.h" +#include "common/ceph_time.h" + #include #include #include @@ -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();