-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: andreidanila1 <andrei.danila@analog.com>
- Loading branch information
1 parent
72ef3a8
commit f74da34
Showing
2 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2025 Analog Devices Inc. | ||
* | ||
* This file is part of Scopy | ||
* (see https://www.github.com/analogdevicesinc/scopy). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#ifndef SCOPYBENCHMARK_H | ||
#define SCOPYBENCHMARK_H | ||
|
||
#include <QElapsedTimer> | ||
#include <QString> | ||
#include "scopy-common_export.h" | ||
|
||
#define CONSOLE_LOG(logger, msg) logger.log(msg, __PRETTY_FUNCTION__, __FILE__, __LINE__) | ||
#define FILE_LOG(logger, msg, path) logger.log(path, msg, __PRETTY_FUNCTION__, __FILE__, __LINE__) | ||
|
||
namespace scopy { | ||
class SCOPY_COMMON_EXPORT ScopyBenchmark | ||
{ | ||
public: | ||
ScopyBenchmark(); | ||
~ScopyBenchmark(); | ||
|
||
void startTimer(); | ||
void restartTimer(); | ||
|
||
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); | ||
|
||
private: | ||
QElapsedTimer m_timer; | ||
}; | ||
|
||
} // namespace scopy | ||
|
||
#endif // SCOPYBENCHMARK_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2025 Analog Devices Inc. | ||
* | ||
* This file is part of Scopy | ||
* (see https://www.github.com/analogdevicesinc/scopy). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include "scopybenchmark.h" | ||
#include <QDate> | ||
#include <QFile> | ||
#include <QLoggingCategory> | ||
|
||
Q_LOGGING_CATEGORY(CAT_BENCHMARK, "Benchmark") | ||
using namespace scopy; | ||
|
||
ScopyBenchmark::ScopyBenchmark() {} | ||
|
||
ScopyBenchmark::~ScopyBenchmark() {} | ||
|
||
void ScopyBenchmark::startTimer() { m_timer.start(); } | ||
|
||
void ScopyBenchmark::restartTimer() { m_timer.restart(); } | ||
|
||
void ScopyBenchmark::log(const QString &msg, const char *function, const char *file, int line) | ||
{ | ||
QMessageLogger(file, line, function).info(CAT_BENCHMARK) << function << msg << m_timer.elapsed() << "ms"; | ||
} | ||
|
||
void ScopyBenchmark::log(const QString &filePath, const QString &msg, const char *function, const char *file, int line) | ||
{ | ||
QFile f(filePath); | ||
if(f.open(QIODevice::WriteOnly | QIODevice::Append)) { | ||
QTextStream stream(&f); | ||
stream << QDateTime::currentDateTime().toString("dd:MM:yyyy hh:mm:ss.zzz") << "\t" << file << ":" | ||
<< line << "\t" << function << "\t" << msg << "\t" << m_timer.elapsed() << "\t" | ||
<< "ms" | ||
<< "\n"; | ||
} | ||
} |