diff --git a/core/src/deviceimpl.cpp b/core/src/deviceimpl.cpp index 67d6c9d01d..9e90ae036a 100644 --- a/core/src/deviceimpl.cpp +++ b/core/src/deviceimpl.cpp @@ -21,7 +21,6 @@ #include "deviceimpl.h" -#include "logging_categories.h" #include "pluginbase/preferences.h" #include "qboxlayout.h" #include "qpushbutton.h" @@ -37,6 +36,7 @@ #include #include +#include #include #include #include @@ -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(p); @@ -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() @@ -81,8 +81,8 @@ void DeviceImpl::preload() void DeviceImpl::loadPlugins() { - QElapsedTimer timer; - timer.start(); + ScopyBenchmark benchmark; + benchmark.startTimer(); removeDisabledPlugins(); preload(); loadName(); @@ -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::const_iterator pI = m_plugins.constEnd(); while(pI != m_plugins.constBegin()) { --pI; @@ -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; } @@ -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(); @@ -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) { @@ -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(); @@ -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"; } diff --git a/core/src/scopymainwindow.cpp b/core/src/scopymainwindow.cpp index f3c6b3f016..a5d5c778d1 100644 --- a/core/src/scopymainwindow.cpp +++ b/core/src/scopymainwindow.cpp @@ -31,6 +31,7 @@ #include #include +#include #include "logging_categories.h" #include "qmessagebox.h" #include "scopymainwindow.h" @@ -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); @@ -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() @@ -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; @@ -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) @@ -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); @@ -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() @@ -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()); @@ -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) @@ -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"; @@ -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()