]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: introduce PerfGuard to PerfCounters. 19149/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 24 Nov 2017 16:38:33 +0000 (17:38 +0100)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 27 Nov 2017 14:16:03 +0000 (15:16 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/common/perf_counters.h

index 362a65229561fe7e379801092bd7db572de73a55..7192d1895c85415d0147b5e0dfbf407cca80f7df 100644 (file)
@@ -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;