Skip to content

Commit

Permalink
common/scopybenchmark: Added logAndReset method.
Browse files Browse the repository at this point in the history
Do we really need these methods? We can call the log method and after
that to call the restart method...

Signed-off-by: andreidanila1 <andrei.danila@analog.com>
  • Loading branch information
andreidanila1 committed Jan 9, 2025
1 parent f74da34 commit f5f2e91
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions common/include/common/scopybenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions common/src/scopybenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit f5f2e91

Please sign in to comment.