From 671fc9144ce9af4ac03b8a2d9abe7901fc771b77 Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Thu, 6 Apr 2017 23:26:35 +0800 Subject: [PATCH] common/perf_counter: make tinc() handle batch-processing Signed-off-by: Jianpeng Ma --- src/common/perf_counters.cc | 12 ++++++------ src/common/perf_counters.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/perf_counters.cc b/src/common/perf_counters.cc index c869880a1e2..f5f0e09e1d2 100644 --- a/src/common/perf_counters.cc +++ b/src/common/perf_counters.cc @@ -241,7 +241,7 @@ uint64_t PerfCounters::get(int idx) const return data.u64.read(); } -void PerfCounters::tinc(int idx, utime_t amt) +void PerfCounters::tinc(int idx, utime_t amt, uint32_t avgcount) { if (!m_cct->_conf->perf) return; @@ -252,15 +252,15 @@ void PerfCounters::tinc(int idx, utime_t amt) if (!(data.type & PERFCOUNTER_TIME)) return; if (data.type & PERFCOUNTER_LONGRUNAVG) { - data.avgcount.inc(); + data.avgcount.add(avgcount); data.u64.add(amt.to_nsec()); - data.avgcount2.inc(); + data.avgcount2.add(avgcount); } else { data.u64.add(amt.to_nsec()); } } -void PerfCounters::tinc(int idx, ceph::timespan amt) +void PerfCounters::tinc(int idx, ceph::timespan amt, uint32_t avgcount) { if (!m_cct->_conf->perf) return; @@ -271,9 +271,9 @@ void PerfCounters::tinc(int idx, ceph::timespan amt) if (!(data.type & PERFCOUNTER_TIME)) return; if (data.type & PERFCOUNTER_LONGRUNAVG) { - data.avgcount.inc(); + data.avgcount.add(avgcount); data.u64.add(amt.count()); - data.avgcount2.inc(); + data.avgcount2.add(avgcount); } else { data.u64.add(amt.count()); } diff --git a/src/common/perf_counters.h b/src/common/perf_counters.h index 11b616c353d..26ad4a6ffb5 100644 --- a/src/common/perf_counters.h +++ b/src/common/perf_counters.h @@ -159,8 +159,8 @@ public: uint64_t get(int idx) const; void tset(int idx, utime_t v); - void tinc(int idx, utime_t v); - void tinc(int idx, ceph::timespan v); + void tinc(int idx, utime_t v, uint32_t avgcount = 1); + void tinc(int idx, ceph::timespan v, uint32_t avgcount = 1); utime_t tget(int idx) const; void hinc(int idx, int64_t x, int64_t y); -- 2.39.5