From ff28e9a1e1288fb76cf3c7a83fb8e0215ba59a7e Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Fri, 24 Nov 2017 17:38:33 +0100 Subject: [PATCH] common: introduce PerfGuard to PerfCounters. Signed-off-by: Radoslaw Zarzynski --- src/common/perf_counters.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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; -- 2.47.3