Skip to content
Permalink
Browse files

Show hotspots for top level items too

  • Loading branch information
nyalldawson committed May 18, 2020
1 parent f48127a commit 3a29831e3f62a0c8c062a1b0d7d550f2cedf5807
Showing with 22 additions and 10 deletions.
  1. +4 −6 src/app/devtools/profiler/qgsprofilerpanelwidget.cpp
  2. +18 −4 src/core/qgsruntimeprofiler.cpp
@@ -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
@@ -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 );
@@ -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()

0 comments on commit 3a29831

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