Skip to content

Commit

Permalink
core: Using the new benchmark infrastructure.
Browse files Browse the repository at this point in the history
Signed-off-by: andreidanila1 <[email protected]>
  • Loading branch information
andreidanila1 committed Jan 9, 2025
1 parent 6ad5839 commit d431dc6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 37 deletions.
45 changes: 23 additions & 22 deletions core/src/deviceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "deviceimpl.h"

#include "logging_categories.h"
#include "pluginbase/preferences.h"
#include "qboxlayout.h"
#include "qpushbutton.h"
Expand All @@ -37,6 +36,7 @@
#include <QtConcurrent/QtConcurrent>
#include <style.h>

#include <common/scopybenchmark.h>
#include <common/scopyconfig.h>
#include <gui/widgets/hoverwidget.h>
#include <gui/widgets/connectionloadingbar.h>
Expand All @@ -58,8 +58,8 @@ DeviceImpl::DeviceImpl(QString param, PluginManager *p, QString category, QObjec

void DeviceImpl::init()
{
QElapsedTimer timer;
timer.start();
ScopyBenchmark benchmark;
benchmark.startTimer();
m_plugins = p->getCompatiblePlugins(m_param, m_category);
for(Plugin *p : qAsConst(m_plugins)) {
QObject *obj = dynamic_cast<QObject *>(p);
Expand All @@ -69,7 +69,7 @@ void DeviceImpl::init()
qWarning(CAT_DEVICEIMPL, "Plugin not a QObject");
}
}
qInfo(CAT_BENCHMARK) << this->displayName() << " init took: " << timer.elapsed() << "ms";
CONSOLE_LOG(benchmark, "Dev init took:");
}

void DeviceImpl::preload()
Expand All @@ -81,8 +81,8 @@ void DeviceImpl::preload()

void DeviceImpl::loadPlugins()
{
QElapsedTimer timer;
timer.start();
ScopyBenchmark benchmark;
benchmark.startTimer();
removeDisabledPlugins();
preload();
loadName();
Expand All @@ -103,13 +103,13 @@ void DeviceImpl::loadPlugins()
p->postload();
}
m_state = DEV_IDLE;
qInfo(CAT_BENCHMARK) << this->displayName() << " plugins load took: " << timer.elapsed() << "ms";
CONSOLE_LOG(benchmark, this->displayName() + " plugins load took:");
}

void DeviceImpl::unloadPlugins()
{
QElapsedTimer timer;
timer.start();
ScopyBenchmark benchmark;
benchmark.startTimer();
QList<Plugin *>::const_iterator pI = m_plugins.constEnd();
while(pI != m_plugins.constBegin()) {
--pI;
Expand All @@ -123,7 +123,7 @@ void DeviceImpl::unloadPlugins()
delete(*pI);
}
m_plugins.clear();
qInfo(CAT_BENCHMARK) << this->displayName() << " plugins unload took: " << timer.elapsed() << "ms";
CONSOLE_LOG(benchmark, this->displayName() + " plugins unload took:");
}

bool DeviceImpl::verify() { return true; }
Expand Down Expand Up @@ -330,12 +330,12 @@ void DeviceImpl::load(QSettings &s)
void DeviceImpl::connectDev()
{
m_state = DEV_CONNECTING;
QElapsedTimer pluginTimer;
QElapsedTimer timer;
ScopyBenchmark pluginConnBm;
ScopyBenchmark connectDevBm;
ConnectionLoadingBar *connectionLoadingBar = new ConnectionLoadingBar();
connectionLoadingBar->setProgressBarMaximum(m_plugins.size());
StatusBarManager::pushUrgentWidget(connectionLoadingBar, "Connection Loading Bar");
timer.start();
connectDevBm.startTimer();
Preferences *pref = Preferences::GetInstance();
bool disconnectDevice = false;
connbtn->hide();
Expand All @@ -348,11 +348,11 @@ void DeviceImpl::connectDev()
Q_EMIT connecting();
QCoreApplication::processEvents();
for(int i = 0; i < m_plugins.size(); ++i) {
pluginTimer.start();
pluginConnBm.startTimer();
connectionLoadingBar->setCurrentPlugin(m_plugins[i]->name());
QCoreApplication::processEvents();
bool pluginConnectionSucceeded = m_plugins[i]->onConnect();
qInfo(CAT_BENCHMARK) << m_plugins[i]->name() << " connection took: " << pluginTimer.elapsed() << "ms";
CONSOLE_LOG(pluginConnBm, m_plugins[i]->name() + " connection took:");
connectionLoadingBar->addProgress(1); // TODO: might change to better reflect the time
QCoreApplication::processEvents();
if(pluginConnectionSucceeded) {
Expand Down Expand Up @@ -390,16 +390,17 @@ void DeviceImpl::connectDev()
m_state = DEV_CONNECTED;
Q_EMIT connected();
delete connectionLoadingBar;
qInfo(CAT_BENCHMARK) << this->displayName() << " device connection took: " << timer.elapsed() << "ms";
CONSOLE_LOG(connectDevBm, this->displayName() + " device connection took:");
}

void DeviceImpl::disconnectDev()
{
QElapsedTimer pluginTimer;
QElapsedTimer timer;
timer.start();
ScopyBenchmark pluginDisconnBm;
ScopyBenchmark disconnectDevBm;
disconnectDevBm.startTimer();
m_state = DEV_DISCONNECTING;
Q_EMIT disconnecting();

unbindPing();
connbtn->show();
discbtn->hide();
Expand All @@ -410,15 +411,15 @@ void DeviceImpl::disconnectDev()
QSettings::IniFormat);
p->saveSettings(s);
}
pluginTimer.start();
pluginDisconnBm.startTimer();
p->onDisconnect();
qInfo(CAT_BENCHMARK) << p->name() << " disconnection took: " << pluginTimer.elapsed() << "ms";
CONSOLE_LOG(pluginDisconnBm, p->name() + " disconnection took:");
}
m_connectedPlugins.clear();
connbtn->setFocus();
m_state = DEV_IDLE;
CONSOLE_LOG(disconnectDevBm, this->displayName() + " device disconnection took:");
Q_EMIT disconnected();
qInfo(CAT_BENCHMARK) << this->displayName() << " device disconnection took: " << timer.elapsed() << "ms";
}

DeviceImpl::~DeviceImpl() { qDebug(CAT_DEVICEIMPL) << m_id << "dtor"; }
Expand Down
31 changes: 16 additions & 15 deletions core/src/scopymainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <deviceautoconnect.h>
#include <style.h>

#include <common/scopybenchmark.h>
#include "logging_categories.h"
#include "qmessagebox.h"
#include "scopymainwindow.h"
Expand Down Expand Up @@ -70,8 +71,8 @@ ScopyMainWindow::ScopyMainWindow(QWidget *parent)
, ui(new Ui::ScopyMainWindow)
, m_glLoader(nullptr)
{
QElapsedTimer timer;
timer.start();
ScopyBenchmark benchmark;
benchmark.startTimer();
initPreferences();
ui->setupUi(this);

Expand Down Expand Up @@ -205,7 +206,7 @@ ScopyMainWindow::ScopyMainWindow(QWidget *parent)
deviceAutoconnect();
prefPage->initSessionDevices();

qInfo(CAT_BENCHMARK) << "ScopyMainWindow constructor took: " << timer.elapsed() << "ms";
CONSOLE_LOG(benchmark, "ScopyMainWindow constructor took:");
}

void ScopyMainWindow::initStatusBar()
Expand Down Expand Up @@ -303,8 +304,8 @@ ScopyMainWindow::~ScopyMainWindow()

void ScopyMainWindow::initAboutPage(PluginManager *pm)
{
QElapsedTimer timer;
timer.start();
ScopyBenchmark benchmark;
benchmark.startTimer();
about = new ScopyAboutPage(this);
if(!pm)
return;
Expand All @@ -315,7 +316,7 @@ void ScopyMainWindow::initAboutPage(PluginManager *pm)
about->addHorizontalTab(about->buildPage(content), p->name());
}
}
qInfo(CAT_BENCHMARK) << " Init about page took: " << timer.elapsed() << "ms";
CONSOLE_LOG(benchmark, "Init about page took:");
}

void ScopyMainWindow::initPreferencesPage(PluginManager *pm)
Expand Down Expand Up @@ -363,8 +364,8 @@ void ScopyMainWindow::setupPreferences()

void ScopyMainWindow::initPreferences()
{
QElapsedTimer timer;
timer.start();
ScopyBenchmark benchmark;
benchmark.startTimer();
QString preferencesPath = scopy::config::preferencesFolderPath() + "/preferences.ini";
Preferences *p = Preferences::GetInstance();
p->setPreferencesFilename(preferencesPath);
Expand Down Expand Up @@ -405,7 +406,7 @@ void ScopyMainWindow::initPreferences()
QString themeName = "scopy-" + theme;
QIcon::setThemeName(themeName);
QIcon::setThemeSearchPaths({":/gui/icons/" + themeName});
qInfo(CAT_BENCHMARK) << "Init preferences took: " << timer.elapsed() << "ms";
CONSOLE_LOG(benchmark, "Init preferences took:");
}

void ScopyMainWindow::loadOpenGL()
Expand Down Expand Up @@ -459,8 +460,8 @@ void ScopyMainWindow::loadOpenGL()
void ScopyMainWindow::loadPluginsFromRepository(PluginRepository *pr)
{

QElapsedTimer timer;
timer.start();
ScopyBenchmark benchmark;
benchmark.startTimer();
// Check the local build plugins folder first
// Check if directory exists and it's not empty
QDir pathDir(scopy::config::localPluginFolderPath());
Expand All @@ -478,7 +479,7 @@ void ScopyMainWindow::loadPluginsFromRepository(PluginRepository *pr)
}
#endif

qInfo(CAT_BENCHMARK) << "Loading the plugins from the repository took: " << timer.elapsed() << "ms";
CONSOLE_LOG(benchmark, "Loading the plugins from the repository took:");
}

void ScopyMainWindow::showEvent(QShowEvent *event)
Expand Down Expand Up @@ -549,8 +550,8 @@ void ScopyMainWindow::initPythonWIN32()

void ScopyMainWindow::loadDecoders()
{
QElapsedTimer timer;
timer.start();
ScopyBenchmark benchmark;
benchmark.startTimer();
#if defined(WITH_SIGROK) && defined(WITH_PYTHON)
#if defined __APPLE__
QString path = QCoreApplication::applicationDirPath() + "/decoders";
Expand Down Expand Up @@ -590,7 +591,7 @@ void ScopyMainWindow::loadDecoders()
#else
qInfo(CAT_SCOPY) << "Python or libsigrokdecode are disabled, can't load decoders";
#endif
qInfo(CAT_BENCHMARK) << "Loading the decoders took: " << timer.elapsed() << "ms";
CONSOLE_LOG(benchmark, "Loading the decoders took:");
}

void ScopyMainWindow::initApi()
Expand Down

0 comments on commit d431dc6

Please sign in to comment.