From f5f2e911cfc817bc50c6abb7533d6b3b3ce30ece Mon Sep 17 00:00:00 2001 From: andreidanila1 Date: Thu, 9 Jan 2025 09:01:31 +0200 Subject: [PATCH] common/scopybenchmark: Added logAndReset method. Do we really need these methods? We can call the log method and after that to call the restart method... Signed-off-by: andreidanila1 --- common/include/common/scopybenchmark.h | 4 ++++ common/src/scopybenchmark.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/common/include/common/scopybenchmark.h b/common/include/common/scopybenchmark.h index 308e47e5f..ee34f080a 100644 --- a/common/include/common/scopybenchmark.h +++ b/common/include/common/scopybenchmark.h @@ -27,7 +27,9 @@ #include "scopy-common_export.h" #define CONSOLE_LOG(logger, msg) logger.log(msg, __PRETTY_FUNCTION__, __FILE__, __LINE__) +#define CONSOLE_LOG_RESET(logger, msg) logger.logAndReset(msg, __PRETTY_FUNCTION__, __FILE__, __LINE__) #define FILE_LOG(logger, msg, path) logger.log(path, msg, __PRETTY_FUNCTION__, __FILE__, __LINE__) +#define FILE_LOG_RESET(logger, msg, path) logger.logAndReset(path, msg, __PRETTY_FUNCTION__, __FILE__, __LINE__) namespace scopy { class SCOPY_COMMON_EXPORT ScopyBenchmark @@ -41,6 +43,8 @@ class SCOPY_COMMON_EXPORT ScopyBenchmark void log(const QString &msg, const char *function, const char *file, int line); void log(const QString &filePath, const QString &msg, const char *function, const char *file, int line); + void logAndReset(const QString &msg, const char *function, const char *file, int line); + void logAndReset(const QString &filePath, const QString &msg, const char *function, const char *file, int line); private: QElapsedTimer m_timer; diff --git a/common/src/scopybenchmark.cpp b/common/src/scopybenchmark.cpp index dc43126bf..1ef7111e5 100644 --- a/common/src/scopybenchmark.cpp +++ b/common/src/scopybenchmark.cpp @@ -51,3 +51,16 @@ void ScopyBenchmark::log(const QString &filePath, const QString &msg, const char << "\n"; } } + +void ScopyBenchmark::logAndReset(const QString &msg, const char *function, const char *file, int line) +{ + log(msg, function, file, line); + m_timer.restart(); +} + +void ScopyBenchmark::logAndReset(const QString &filePath, const QString &msg, const char *function, const char *file, + int line) +{ + log(filePath, msg, function, file, line); + m_timer.restart(); +}