Skip to content
Permalink
Browse files

Move profiler instance to QgsApplication

  • Loading branch information
NathanW2 authored and nyalldawson committed Nov 23, 2016
1 parent ee80be4 commit 311f4827253c88e2bc62a591c661535e1f997115
@@ -1363,6 +1363,10 @@ QgsRuleBasedRendererWidget {#qgis_api_break_3_0_QgsRuleBasedRendererWidge

- refineRuleCategoriesGui() and refineRuleRangesGui() no longer take a QModelIndexList argument.

QgsRuntimeProfiler {#qgis_api_break_3_0_QgsRuntimeProfiler}
------------------

- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::profiler() to access an application-wide profiler.

QgsSimpleMarkerSymbolLayer {#qgis_api_break_3_0_QgsSimpleMarkerSymbolLayer}
--------------------------
@@ -385,6 +385,12 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
*/
static QgsActionScopeRegistry* actionScopeRegistry();

/**
* Returns the application runtime profiler.
* @note added in QGIS 3.0
*/
static QgsRuntimeProfiler* profiler();

public slots:

/** Causes the application instance to emit the settingsChanged() signal. This should
@@ -11,13 +11,6 @@ class QgsRuntimeProfiler
*/
QgsRuntimeProfiler();

/**
* @brief Begin the group for the profiler. Groups will append {GroupName}/ to the
* front of the profile tag set using start.
* @param name The name of the group.
*/
static QgsRuntimeProfiler * instance();

/**
* @brief Begin the group for the profiler. Groups will append {GroupName}/ to the
* front of the profile tag set using start.
@@ -564,7 +564,6 @@ QgisApp *QgisApp::smInstance = nullptr;
// constructor starts here
QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCheck, QWidget * parent, Qt::WindowFlags fl )
: QMainWindow( parent, fl )
, mProfiler( nullptr )
, mNonEditMapTool( nullptr )
, mScaleWidget( nullptr )
, mMagnifierWidget( nullptr )
@@ -609,13 +608,13 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
}

smInstance = this;
mProfiler = QgsRuntimeProfiler::instance();
QgsRuntimeProfiler* profiler = QgsApplication::profiler();

namSetup();

// load GUI: actions, menus, toolbars
mProfiler->beginGroup( QStringLiteral( "qgisapp" ) );
mProfiler->beginGroup( QStringLiteral( "startup" ) );
profiler->beginGroup( QStringLiteral( "qgisapp" ) );
profiler->beginGroup( QStringLiteral( "startup" ) );
startProfile( QStringLiteral( "Setting up UI" ) );
setupUi( this );
endProfile();
@@ -1105,13 +1104,12 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
#ifdef ANDROID
toggleFullScreen();
#endif
mProfiler->endGroup();
mProfiler->endGroup();
profiler->endGroup();

QgsDebugMsg( "PROFILE TIMES" );
QgsDebugMsg( QString( "PROFILE TIMES TOTAL - %1 " ).arg( mProfiler->totalTime() ) );
QgsDebugMsg( QString( "PROFILE TIMES TOTAL - %1 " ).arg( profiler->totalTime() ) );
#ifdef QGISDEBUG
QList<QPair<QString, double> > profileTimes = mProfiler->profileTimes();
QList<QPair<QString, double> > profileTimes = profiler->profileTimes();
QList<QPair<QString, double> >::const_iterator it = profileTimes.constBegin();
for ( ; it != profileTimes.constEnd(); ++it )
{
@@ -1125,7 +1123,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh

QgisApp::QgisApp()
: QMainWindow( nullptr, 0 )
, mProfiler( nullptr )
, mStyleSheetBuilder( nullptr )
, mActionPluginSeparator1( nullptr )
, mActionPluginSeparator2( nullptr )
@@ -11265,12 +11262,12 @@ void QgisApp::onSnappingConfigChanged()

void QgisApp::startProfile( const QString& name )
{
mProfiler->start( name );
QgsApplication::profiler()->start( name );
}

void QgisApp::endProfile()
{
mProfiler->end();
QgsApplication::profiler()->end();
}

void QgisApp::functionProfile( void ( QgisApp::*fnc )(), QgisApp* instance, QString name )
@@ -1430,8 +1430,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void endProfile();
void functionProfile( void ( QgisApp::*fnc )(), QgisApp *instance, QString name );

QgsRuntimeProfiler* mProfiler;

/** This method will open a dialog so the user can select GDAL sublayers to load
* @returns true if any items were loaded
*/
@@ -24,6 +24,7 @@
#include "qgsproviderregistry.h"
#include "qgsexpression.h"
#include "qgsactionscoperegistry.h"
#include "qgsruntimeprofiler.h"

#include <QDir>
#include <QFile>
@@ -104,6 +105,7 @@ QgsApplication::QgsApplication( int & argc, char ** argv, bool GUIenabled, const
{
sPlatformName = platformName;

mProfiler = new QgsRuntimeProfiler();
mActionScopeRegistry = new QgsActionScopeRegistry();

init( customConfigPath ); // init can also be called directly by e.g. unit tests that don't inherit QApplication.
@@ -237,6 +239,7 @@ void QgsApplication::init( QString customConfigPath )
QgsApplication::~QgsApplication()
{
delete mActionScopeRegistry;
delete mProfiler;
}

QgsApplication* QgsApplication::instance()
@@ -310,6 +313,11 @@ bool QgsApplication::notify( QObject * receiver, QEvent * event )
return done;
}

QgsRuntimeProfiler *QgsApplication::profiler()
{
return instance()->mProfiler;
}

void QgsApplication::setFileOpenEventReceiver( QObject * receiver )
{
// Set receiver for FileOpen events
@@ -23,6 +23,7 @@
#include <qgsconfig.h>

class QgsActionScopeRegistry;
class QgsRuntimeProfiler;

/** \ingroup core
* Extends QApplication to provide access to QGIS specific resources such
@@ -381,6 +382,12 @@ class CORE_EXPORT QgsApplication : public QApplication
*/
static QgsActionScopeRegistry* actionScopeRegistry();

/**
* Returns the application runtime profiler.
* @note added in QGIS 3.0
*/
static QgsRuntimeProfiler* profiler();

public slots:

/** Causes the application instance to emit the settingsChanged() signal. This should
@@ -448,6 +455,7 @@ class CORE_EXPORT QgsApplication : public QApplication
QMap<QString, QIcon> mIconCache;

QgsActionScopeRegistry* mActionScopeRegistry;
QgsRuntimeProfiler* mProfiler;
};

#endif
@@ -2,15 +2,6 @@
#include "qgslogger.h"


QgsRuntimeProfiler* QgsRuntimeProfiler::mInstance = nullptr;

QgsRuntimeProfiler* QgsRuntimeProfiler::instance()
{
if ( !mInstance )
mInstance = new QgsRuntimeProfiler();
return mInstance;
}

QgsRuntimeProfiler::QgsRuntimeProfiler()
{

@@ -17,13 +17,6 @@ class CORE_EXPORT QgsRuntimeProfiler
*/
QgsRuntimeProfiler();

/**
* @brief Instance of the run time profiler. To use the main profiler
* use this instance.
* @return The instance of the run time profiler
*/
static QgsRuntimeProfiler * instance();

/**
* @brief Begin the group for the profiler. Groups will append {GroupName}/ to the
* front of the profile tag set using start.
@@ -67,8 +60,6 @@ class CORE_EXPORT QgsRuntimeProfiler
double totalTime();

private:
static QgsRuntimeProfiler* mInstance;

QString mGroupPrefix;
QStack<QString> mGroupStack;
QTime mProfileTime;

0 comments on commit 311f482

Please sign in to comment.
You can’t perform that action at this time.