Skip to content

Commit

Permalink
Show hotspots for top level items too
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 18, 2020
1 parent f48127a commit 3a29831
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
10 changes: 4 additions & 6 deletions src/app/devtools/profiler/qgsprofilerpanelwidget.cpp
Expand Up @@ -40,11 +40,8 @@ QgsProfilerPanelWidget::QgsProfilerPanelWidget( QgsRuntimeProfiler *profiler, QW
{
double profileTime = mProfiler->profileTime( topLevel.isEmpty() ? child : topLevel + '/' + child );
QTreeWidgetItem *item = new QTreeWidgetItem( QStringList() << child << QString::number( profileTime ) );
if ( !topLevel.isEmpty() )
{
item->setData( 1, Qt::UserRole + 1, parentCost * 1000 );
item->setData( 1, Qt::InitialSortOrderRole, profileTime * 1000 );
}
item->setData( 1, Qt::UserRole + 1, parentCost * 1000 );
item->setData( 1, Qt::InitialSortOrderRole, profileTime * 1000 );
if ( !parentItem )
mTreeWidget->addTopLevelItem( item );
else
Expand All @@ -53,7 +50,8 @@ QgsProfilerPanelWidget::QgsProfilerPanelWidget( QgsRuntimeProfiler *profiler, QW
addGroup( topLevel.isEmpty() ? child : topLevel + '/' + child, item, profileTime );
}
};
addGroup( QString(), nullptr, 0 );
const double totalTime = mProfiler->profileTime( QString() );
addGroup( QString(), nullptr, totalTime );

mTreeWidget->resizeColumnToContents( 0 );
mTreeWidget->resizeColumnToContents( 1 );
Expand Down
22 changes: 18 additions & 4 deletions src/core/qgsruntimeprofiler.cpp
Expand Up @@ -80,12 +80,26 @@ void QgsRuntimeProfiler::end()

double QgsRuntimeProfiler::profileTime( const QString &name ) const
{
for ( auto it = mProfileTimes.constBegin(); it != mProfileTimes.constEnd(); ++it )
if ( !name.isEmpty() )
{
if ( it->first == name )
return it->second;
for ( auto it = mProfileTimes.constBegin(); it != mProfileTimes.constEnd(); ++it )
{
if ( it->first == name )
return it->second;
}
return -1;
}
else
{
// collect total time for top level items
double totalTime = 0;
for ( auto it = mProfileTimes.constBegin(); it != mProfileTimes.constEnd(); ++it )
{
if ( it->first.count( '/' ) == 0 )
totalTime += it->second;
}
return totalTime;
}
return -1;
}

void QgsRuntimeProfiler::clear()
Expand Down

0 comments on commit 3a29831

Please sign in to comment.