@@ -587,14 +587,20 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
587
587
}
588
588
589
589
smInstance = this ;
590
+ profiler = QgsRuntimeProfiler::instance ();
590
591
591
592
namSetup ();
592
593
593
594
// load GUI: actions, menus, toolbars
595
+ profiler->beginGroup ( " qgisapp" );
596
+ profiler->beginGroup ( " startup" );
597
+ startProfile ( " Setting up UI" );
594
598
setupUi ( this );
599
+ endProfile ();
595
600
596
601
// ////////
597
602
603
+ startProfile ( " Checking database" );
598
604
mSplash ->showMessage ( tr ( " Checking database" ), Qt::AlignHCenter | Qt::AlignBottom );
599
605
qApp->processEvents ();
600
606
// Do this early on before anyone else opens it and prevents us copying it
@@ -603,17 +609,22 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
603
609
{
604
610
QMessageBox::critical ( this , tr ( " Private qgis.db" ), dbError );
605
611
}
612
+ endProfile ();
606
613
614
+ startProfile ( " Initializing authentication" );
607
615
mSplash ->showMessage ( tr ( " Initializing authentication" ), Qt::AlignHCenter | Qt::AlignBottom );
608
616
qApp->processEvents ();
609
617
QgsAuthManager::instance ()->init ( QgsApplication::pluginPath () );
610
618
if ( !QgsAuthManager::instance ()->isDisabled () )
611
619
{
612
620
masterPasswordSetup ();
613
621
}
622
+ endProfile ();
614
623
615
624
// Create the themes folder for the user
625
+ startProfile ( " Creating theme folder" );
616
626
QgsApplication::createThemeFolder ();
627
+ endProfile ();
617
628
618
629
mSplash ->showMessage ( tr ( " Reading settings" ), Qt::AlignHCenter | Qt::AlignBottom );
619
630
qApp->processEvents ();
@@ -623,18 +634,21 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
623
634
624
635
QSettings settings;
625
636
637
+ startProfile ( " Building style sheet" );
626
638
// set up stylesheet builder and apply saved or default style options
627
639
mStyleSheetBuilder = new QgisAppStyleSheet ( this );
628
640
connect ( mStyleSheetBuilder , SIGNAL ( appStyleSheetChanged ( const QString& ) ),
629
641
this , SLOT ( setAppStyleSheet ( const QString& ) ) );
630
642
mStyleSheetBuilder ->buildStyleSheet ( mStyleSheetBuilder ->defaultOptions () );
643
+ endProfile ();
631
644
632
645
QWidget *centralWidget = this ->centralWidget ();
633
646
QGridLayout *centralLayout = new QGridLayout ( centralWidget );
634
647
centralWidget->setLayout ( centralLayout );
635
648
centralLayout->setContentsMargins ( 0 , 0 , 0 , 0 );
636
649
637
650
// "theMapCanvas" used to find this canonical instance later
651
+ startProfile ( " Creating map canvas" );
638
652
mMapCanvas = new QgsMapCanvas ( centralWidget, " theMapCanvas" );
639
653
connect ( mMapCanvas , SIGNAL ( messageEmitted ( const QString&, const QString&, QgsMessageBar::MessageLevel ) ),
640
654
this , SLOT ( displayMessage ( const QString&, const QString&, QgsMessageBar::MessageLevel ) ) );
@@ -646,11 +660,15 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
646
660
int myGreen = settings.value ( " /qgis/default_canvas_color_green" , 255 ).toInt ();
647
661
int myBlue = settings.value ( " /qgis/default_canvas_color_blue" , 255 ).toInt ();
648
662
mMapCanvas ->setCanvasColor ( QColor ( myRed, myGreen, myBlue ) );
663
+ endProfile ();
649
664
650
665
// what type of project to auto-open
651
666
mProjOpen = settings.value ( " /qgis/projOpenAtLaunch" , 0 ).toInt ();
652
667
668
+
669
+ startProfile ( " Welcome page" );
653
670
mWelcomePage = new QgsWelcomePage ( skipVersionCheck );
671
+ endProfile ();
654
672
655
673
mCentralContainer = new QStackedWidget;
656
674
mCentralContainer ->insertWidget ( 0 , mMapCanvas );
@@ -663,59 +681,75 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
663
681
mCentralContainer ->setCurrentIndex ( mProjOpen ? 0 : 1 );
664
682
665
683
// a bar to warn the user with non-blocking messages
684
+ startProfile ( " Message bar" );
666
685
mInfoBar = new QgsMessageBar ( centralWidget );
667
686
mInfoBar ->setSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Fixed );
668
687
centralLayout->addWidget ( mInfoBar , 0 , 0 , 1 , 1 );
688
+ endProfile ();
669
689
690
+ startProfile ( " User input dock" );
670
691
// User Input Dock Widget
671
692
mUserInputDockWidget = new QgsUserInputDockWidget ( this );
672
693
mUserInputDockWidget ->setObjectName ( " UserInputDockWidget" );
694
+ endProfile ();
673
695
674
696
// set the focus to the map canvas
675
697
mMapCanvas ->setFocus ();
676
698
699
+ startProfile ( " Layer tree" );
677
700
mLayerTreeView = new QgsLayerTreeView ( this );
678
701
mLayerTreeView ->setObjectName ( " theLayerTreeView" ); // "theLayerTreeView" used to find this canonical instance later
702
+ endProfile ();
679
703
680
704
// create undo widget
705
+ startProfile ( " Undo dock" );
681
706
mUndoDock = new QDockWidget ( tr ( " Undo/Redo Panel" ), this );
682
707
mUndoWidget = new QgsUndoWidget ( mUndoDock , mMapCanvas );
683
708
mUndoWidget ->setObjectName ( " Undo" );
684
709
mUndoDock ->setWidget ( mUndoWidget );
685
710
mUndoDock ->setObjectName ( " undo/redo dock" );
711
+ endProfile ();
686
712
687
713
// Advanced Digitizing dock
714
+ startProfile ( " Advanced digitize panel" );
688
715
mAdvancedDigitizingDockWidget = new QgsAdvancedDigitizingDockWidget ( mMapCanvas , this );
689
716
mAdvancedDigitizingDockWidget ->setObjectName ( " AdvancedDigitizingTools" );
717
+ endProfile ();
690
718
691
719
// Statistical Summary dock
720
+ startProfile ( " Stats dock" );
692
721
mStatisticalSummaryDockWidget = new QgsStatisticalSummaryDockWidget ( this );
693
722
mStatisticalSummaryDockWidget ->setObjectName ( " StatistalSummaryDockWidget" );
723
+ endProfile ();
694
724
695
725
// Bookmarks dock
726
+ startProfile ( " Bookmarks widget" );
696
727
mBookMarksDockWidget = new QgsBookmarks ( this );
697
728
mBookMarksDockWidget ->setObjectName ( " BookmarksDockWidget" );
729
+ endProfile ();
698
730
731
+ startProfile ( " Snapping utils" );
699
732
mSnappingUtils = new QgsMapCanvasSnappingUtils ( mMapCanvas , this );
700
733
mMapCanvas ->setSnappingUtils ( mSnappingUtils );
701
734
connect ( QgsProject::instance (), SIGNAL ( snapSettingsChanged () ), mSnappingUtils , SLOT ( readConfigFromProject () ) );
702
735
connect ( this , SIGNAL ( projectRead () ), mSnappingUtils , SLOT ( readConfigFromProject () ) );
703
-
704
- createActions ();
705
- createActionGroups ();
706
- createMenus ();
707
- createToolBars ();
708
- createStatusBar ();
709
- createCanvasTools ();
736
+ endProfile ();
737
+
738
+ functionProfile ( &QgisApp::createActions, this , " Create actions" );
739
+ functionProfile ( &QgisApp::createActionGroups, this , " Create action group" );
740
+ functionProfile ( &QgisApp::createMenus, this , " Create menus" );
741
+ functionProfile ( &QgisApp::createToolBars, this , " Toolbars" );
742
+ functionProfile ( &QgisApp::createStatusBar, this , " Status bar" );
743
+ functionProfile ( &QgisApp::createCanvasTools, this , " Create canvas tools" );
710
744
mMapCanvas ->freeze ();
711
- initLayerTreeView ( );
712
- createOverview ( );
713
- createMapTips ( );
714
- createDecorations ( );
715
- readSettings ( );
716
- updateRecentProjectPaths ( );
717
- updateProjectFromTemplates ( );
718
- legendLayerSelectionChanged ( );
745
+ functionProfile ( &QgisApp::initLayerTreeView, this , " Init Layer tree view " );
746
+ functionProfile ( &QgisApp::createOverview, this , " Create overview " );
747
+ functionProfile ( &QgisApp::createMapTips, this , " Create map tips " );
748
+ functionProfile ( &QgisApp::createDecorations, this , " Create decorations " );
749
+ functionProfile ( &QgisApp::readSettings, this , " Read settings " );
750
+ functionProfile ( &QgisApp::updateRecentProjectPaths, this , " Update recent project paths " );
751
+ functionProfile ( &QgisApp::updateProjectFromTemplates, this , " Update project from templates " );
752
+ functionProfile ( &QgisApp::legendLayerSelectionChanged, this , " Legend layer selection changed " );
719
753
mSaveRollbackInProgress = false ;
720
754
721
755
QFileSystemWatcher* projectsTemplateWatcher = new QFileSystemWatcher ( this );
@@ -725,11 +759,14 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
725
759
connect ( projectsTemplateWatcher, SIGNAL ( directoryChanged ( QString ) ), this , SLOT ( updateProjectFromTemplates () ) );
726
760
727
761
// initialize the plugin manager
762
+ startProfile ( " Plugin manager" );
728
763
mPluginManager = new QgsPluginManager ( this , restorePlugins );
764
+ endProfile ();
729
765
730
766
addDockWidget ( Qt::LeftDockWidgetArea, mUndoDock );
731
767
mUndoDock ->hide ();
732
768
769
+ startProfile ( " Map Style dock" );
733
770
mMapStylingDock = new QDockWidget ( this );
734
771
mMapStylingDock ->setWindowTitle ( tr ( " Map Styling" ) );
735
772
mMapStylingDock ->setObjectName ( " MapStyling" );
@@ -740,9 +777,12 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
740
777
741
778
addDockWidget ( Qt::RightDockWidgetArea, mMapStylingDock );
742
779
mMapStylingDock ->hide ();
780
+ endProfile ();
743
781
782
+ startProfile ( " Snapping dialog" );
744
783
mSnappingDialog = new QgsSnappingDialog ( this , mMapCanvas );
745
784
mSnappingDialog ->setObjectName ( " SnappingOption" );
785
+ endProfile ();
746
786
747
787
mBrowserWidget = new QgsBrowserDockWidget ( tr ( " Browser Panel" ), this );
748
788
mBrowserWidget ->setObjectName ( " Browser" );
@@ -864,11 +904,13 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
864
904
865
905
if ( mPythonUtils && mPythonUtils ->isEnabled () )
866
906
{
907
+ startProfile ( " initPluginInstaller" );
867
908
// initialize the plugin installer to start fetching repositories in background
868
909
QgsPythonRunner::run ( " import pyplugin_installer" );
869
910
QgsPythonRunner::run ( " pyplugin_installer.initPluginInstaller()" );
870
911
// enable Python in the Plugin Manager and pass the PythonUtils to it
871
912
mPluginManager ->setPythonUtils ( mPythonUtils );
913
+ endProfile ();
872
914
}
873
915
else if ( mActionShowPythonDialog )
874
916
{
@@ -911,10 +953,14 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
911
953
//
912
954
mSplash ->showMessage ( tr ( " Restoring window state" ), Qt::AlignHCenter | Qt::AlignBottom );
913
955
qApp->processEvents ();
956
+ startProfile ( " Restore window state" );
914
957
restoreWindowState ();
958
+ endProfile ();
915
959
916
960
// do main window customization - after window state has been restored, before the window is shown
961
+ startProfile ( " Update customiziation on main window" );
917
962
QgsCustomization::instance ()->updateMainWindow ( mToolbarMenu );
963
+ endProfile ();
918
964
919
965
mSplash ->showMessage ( tr ( " QGIS Ready!" ), Qt::AlignHCenter | Qt::AlignBottom );
920
966
@@ -936,8 +982,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
936
982
937
983
mFullScreenMode = false ;
938
984
mPrevScreenModeMaximized = false ;
985
+ startProfile ( " Show main window" );
939
986
show ();
940
987
qApp->processEvents ();
988
+ endProfile ();
941
989
942
990
mMapCanvas ->freeze ( false );
943
991
mMapCanvas ->clearExtentHistory (); // reset zoomnext/zoomlast
@@ -994,7 +1042,9 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
994
1042
// notify user if authentication system is disabled
995
1043
( void )QgsAuthGuiUtils::isDisabled ( messageBar () );
996
1044
1045
+ startProfile ( " New project" );
997
1046
fileNewBlank (); // prepare empty project, also skips any default templates from loading
1047
+ endProfile ();
998
1048
999
1049
// request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
1000
1050
// should come after fileNewBlank to ensure project is properly set up to receive any data source files
@@ -1004,6 +1054,19 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
1004
1054
#ifdef ANDROID
1005
1055
toggleFullScreen ();
1006
1056
#endif
1057
+ profiler->endGroup ();
1058
+ profiler->endGroup ();
1059
+
1060
+ QgsDebugMsg ( " PROFILE TIMES" );
1061
+ QgsDebugMsg ( QString ( " PROFILE TIMES TOTAL - %1 " ).arg ( profiler->totalTime () ) );
1062
+ QList<QPair<QString, double > >::const_iterator it = profiler->profileTimes ().constBegin ();
1063
+ for ( ; it != profiler->profileTimes ().constEnd (); ++it )
1064
+ {
1065
+ QString name = ( *it ).first ;
1066
+ double time = ( *it ).second ;
1067
+ QgsDebugMsg ( QString ( " - %1 - %2" ).arg ( name ).arg ( time ) );
1068
+ }
1069
+
1007
1070
} // QgisApp ctor
1008
1071
1009
1072
QgisApp::QgisApp ()
@@ -10960,6 +11023,23 @@ void QgisApp::keyPressEvent( QKeyEvent * e )
10960
11023
}
10961
11024
}
10962
11025
11026
+ void QgisApp::startProfile ( const QString& name )
11027
+ {
11028
+ profiler->start ( name );
11029
+ }
11030
+
11031
+ void QgisApp::endProfile ()
11032
+ {
11033
+ profiler->end ();
11034
+ }
11035
+
11036
+ void QgisApp::functionProfile ( void ( QgisApp::*fnc )(), QgisApp* instance, QString name )
11037
+ {
11038
+ startProfile ( name );
11039
+ ( instance->*fnc )();
11040
+ endProfile ();
11041
+ }
11042
+
10963
11043
void QgisApp::mapCanvas_keyPressed ( QKeyEvent *e )
10964
11044
{
10965
11045
// Delete selected features when it is possible and KeyEvent was not managed by current MapTool
0 commit comments