From: Radoslaw Zarzynski Date: Fri, 24 Nov 2017 16:38:33 +0000 (+0100) Subject: common: introduce PerfGuard to PerfCounters. X-Git-Tag: v13.0.1~75^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F19149%2Fhead;p=ceph.git common: introduce PerfGuard to PerfCounters. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/common/perf_counters.h b/src/common/perf_counters.h index 362a65229561f..7192d1895c854 100644 --- a/src/common/perf_counters.h +++ b/src/common/perf_counters.h @@ -352,6 +352,24 @@ private: }; +class PerfGuard { + const ceph::real_clock::time_point start; + PerfCounters* const counters; + const int event; + +public: + PerfGuard(PerfCounters* const counters, + const int event) + : start(ceph::real_clock::now()), + counters(counters), + event(event) { + } + + ~PerfGuard() { + counters->tinc(event, ceph::real_clock::now() - start); + } +}; + class PerfCountersDeleter { CephContext* cct;