forked from qt-creator/qt-creator
ExtensionSystem: Factor out startup performance summary
Makes it possible to potentially show it after the fact. Change-Id: I7c93a2a290bf1a3e096286a3d20fd4553757ad5c Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -947,7 +947,7 @@ void PluginManagerPrivate::nextDelayedInitialize()
|
|||||||
delayedInitializeTimer = nullptr;
|
delayedInitializeTimer = nullptr;
|
||||||
if (m_profileTimer)
|
if (m_profileTimer)
|
||||||
m_totalStartupMS = m_profileTimer->elapsed();
|
m_totalStartupMS = m_profileTimer->elapsed();
|
||||||
profilingSummary();
|
printProfilingSummary();
|
||||||
emit q->initializationDone();
|
emit q->initializationDone();
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
if (PluginManager::testRunRequested())
|
if (PluginManager::testRunRequested())
|
||||||
@@ -1787,12 +1787,13 @@ void PluginManagerPrivate::profilingReport(const char *what, const PluginSpec *s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginManagerPrivate::profilingSummary() const
|
QString PluginManagerPrivate::profilingSummary(qint64 *totalOut) const
|
||||||
{
|
{
|
||||||
if (m_profilingVerbosity > 0) {
|
QString summary;
|
||||||
const QVector<PluginSpec *> specs
|
const QVector<PluginSpec *> specs = Utils::sorted(pluginSpecs,
|
||||||
= Utils::sorted(pluginSpecs, [](PluginSpec *s1, PluginSpec *s2) {
|
[](PluginSpec *s1, PluginSpec *s2) {
|
||||||
return s1->performanceData().total() < s2->performanceData().total();
|
return s1->performanceData().total()
|
||||||
|
< s2->performanceData().total();
|
||||||
});
|
});
|
||||||
const qint64 total
|
const qint64 total
|
||||||
= std::accumulate(specs.constBegin(), specs.constEnd(), 0, [](qint64 t, PluginSpec *s) {
|
= std::accumulate(specs.constBegin(), specs.constEnd(), 0, [](qint64 t, PluginSpec *s) {
|
||||||
@@ -1802,10 +1803,24 @@ void PluginManagerPrivate::profilingSummary() const
|
|||||||
if (!s->isEffectivelyEnabled())
|
if (!s->isEffectivelyEnabled())
|
||||||
continue;
|
continue;
|
||||||
const qint64 t = s->performanceData().total();
|
const qint64 t = s->performanceData().total();
|
||||||
qDebug("%-22s %8lldms ( %5.2f%% )", qPrintable(s->name()), t, 100.0 * t / total);
|
summary += QString("%1 %2ms ( %3% )\n")
|
||||||
|
.arg(s->name(), -22)
|
||||||
|
.arg(t, 8)
|
||||||
|
.arg(100.0 * t / total, 5, 'f', 2);
|
||||||
}
|
}
|
||||||
qDebug("Total plugins: %8lldms", total);
|
summary += QString("Total plugins: %1ms\n").arg(total, 8);
|
||||||
qDebug("Total startup: %8lldms", m_totalStartupMS);
|
summary += QString("Total startup: %1ms\n").arg(m_totalStartupMS, 8);
|
||||||
|
if (totalOut)
|
||||||
|
*totalOut = total;
|
||||||
|
return summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PluginManagerPrivate::printProfilingSummary() const
|
||||||
|
{
|
||||||
|
if (m_profilingVerbosity > 0) {
|
||||||
|
qint64 total;
|
||||||
|
const QString summary = profilingSummary(&total);
|
||||||
|
qDebug() << qPrintable(summary);
|
||||||
Utils::Benchmarker::report("loadPlugins", "Total", total);
|
Utils::Benchmarker::report("loadPlugins", "Total", total);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -59,7 +59,8 @@ public:
|
|||||||
void resolveDependencies();
|
void resolveDependencies();
|
||||||
void enableDependenciesIndirectly();
|
void enableDependenciesIndirectly();
|
||||||
void increaseProfilingVerbosity();
|
void increaseProfilingVerbosity();
|
||||||
void profilingSummary() const;
|
QString profilingSummary(qint64 *totalOut = nullptr) const;
|
||||||
|
void printProfilingSummary() const;
|
||||||
void profilingReport(const char *what, const PluginSpec *spec, qint64 *target = nullptr);
|
void profilingReport(const char *what, const PluginSpec *spec, qint64 *target = nullptr);
|
||||||
void setSettings(Utils::QtcSettings *settings);
|
void setSettings(Utils::QtcSettings *settings);
|
||||||
void setGlobalSettings(Utils::QtcSettings *settings);
|
void setGlobalSettings(Utils::QtcSettings *settings);
|
||||||
|
Reference in New Issue
Block a user