Skip to content

Commit

Permalink
Some wms provider profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 28, 2020
1 parent e8a15c1 commit 41c91bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -54,6 +54,7 @@ email : tim at linfiniti.com
#include "qgsbilinearrasterresampler.h"
#include "qgscubicrasterresampler.h"
#include "qgsrasterlayertemporalproperties.h"
#include "qgsruntimeprofiler.h"

#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -622,6 +623,10 @@ void QgsRasterLayer::setDataProvider( QString const &provider, const QgsDataProv

//mBandCount = 0;

std::unique_ptr< QgsScopedRuntimeProfile > profile;
if ( QgsApplication::profiler()->groupIsActive( QStringLiteral( "projectload" ) ) )
profile = qgis::make_unique< QgsScopedRuntimeProfile >( tr( "Create %1 provider" ).arg( provider ), QStringLiteral( "projectload" ) );

mDataProvider = qobject_cast< QgsRasterDataProvider * >( QgsProviderRegistry::instance()->createProvider( mProviderKey, mDataSource, options ) );
if ( !mDataProvider )
{
Expand Down
15 changes: 15 additions & 0 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -50,6 +50,7 @@
#include "qgssettings.h"
#include "qgsogrutils.h"
#include "qgsproviderregistry.h"
#include "qgsruntimeprofiler.h"

#include <QNetworkRequest>
#include <QNetworkReply>
Expand Down Expand Up @@ -122,8 +123,13 @@ QgsWmsProvider::QgsWmsProvider( QString const &uri, const ProviderOptions &optio
if ( !addLayers() )
return;

std::unique_ptr< QgsScopedRuntimeProfile > profile;

if ( mSettings.mIsMBTiles )
{
if ( QgsApplication::profiler()->groupIsActive( QStringLiteral( "projectload" ) ) )
profile = qgis::make_unique< QgsScopedRuntimeProfile >( tr( "Setup tile capabilities" ), QStringLiteral( "projectload" ) );

// we are dealing with a local MBTiles file
if ( !setupMBTilesCapabilities( uri ) )
{
Expand All @@ -133,6 +139,9 @@ QgsWmsProvider::QgsWmsProvider( QString const &uri, const ProviderOptions &optio
}
else if ( mSettings.mXyz )
{
if ( QgsApplication::profiler()->groupIsActive( QStringLiteral( "projectload" ) ) )
profile = qgis::make_unique< QgsScopedRuntimeProfile >( tr( "Setup tile capabilities" ), QStringLiteral( "projectload" ) );

// we are working with XYZ tiles
// no need to get capabilities, the whole definition is in URI
// so we just generate a dummy WMTS definition
Expand All @@ -146,6 +155,9 @@ QgsWmsProvider::QgsWmsProvider( QString const &uri, const ProviderOptions &optio
if ( capabilities )
mCaps = *capabilities;

if ( QgsApplication::profiler()->groupIsActive( QStringLiteral( "projectload" ) ) )
profile = qgis::make_unique< QgsScopedRuntimeProfile >( tr( "Retrieve server capabilities" ), QStringLiteral( "projectload" ) );

// Make sure we have capabilities - other functions here may need them
if ( !retrieveServerCapabilities() )
{
Expand Down Expand Up @@ -176,6 +188,9 @@ QgsWmsProvider::QgsWmsProvider( QString const &uri, const ProviderOptions &optio
}
mCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( mSettings.mCrsId );

if ( profile )
profile->switchTask( tr( "Calculate extent" ) );

if ( !calculateExtent() || mLayerExtent.isEmpty() )
{
appendError( ERR( tr( "Cannot calculate extent" ) ) );
Expand Down

0 comments on commit 41c91bb

Please sign in to comment.