Merge pull request #19149 from rzarzynski/wip-common-perfguards

common:  RAII-styled mechanism for updating PerfCounters

Reviewed-by: Haomai Wang <haomai@xsky.com>
Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2017-11-29 16:12:57 +08:00 committed by GitHub
commit f05b093f02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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;