From 555f0f2ba30da214041a401989486bb9edd2e964 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 13 Feb 2024 14:38:17 +0800 Subject: [PATCH] exporter: remove BlockTimer::ms this member variable is redundant. Signed-off-by: Kefu Chai --- src/exporter/util.cc | 6 +++--- src/exporter/util.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/exporter/util.cc b/src/exporter/util.cc index d4453ba797b..6def113a5d4 100644 --- a/src/exporter/util.cc +++ b/src/exporter/util.cc @@ -18,12 +18,13 @@ BlockTimer::BlockTimer(std::string file, std::string function) t1 = clock_t::now(); } BlockTimer::~BlockTimer() { - dout(20) << file << ":" << function << ": " << ms.count() << "ms" << dendl; + dout(20) << file << ":" << function << ": " << get_ms() << "ms" << dendl; } // useful with stop double BlockTimer::get_ms() const { - return ms.count(); + using milliseconds_t = std::chrono::duration; + return std::chrono::duration_cast(t2 - t1).count(); } // Manually stop the timer as you might want to get the time @@ -31,7 +32,6 @@ void BlockTimer::stop() { if (!stopped) { stopped = true; t2 = clock_t::now(); - ms = t2 - t1; } } diff --git a/src/exporter/util.h b/src/exporter/util.h index 07598d9e825..2f4eaebb615 100644 --- a/src/exporter/util.h +++ b/src/exporter/util.h @@ -9,7 +9,6 @@ class BlockTimer { void stop(); double get_ms() const; private: - std::chrono::duration ms; std::string file, function; bool stopped; using clock_t = std::chrono::steady_clock; -- 2.39.5