Commit edfd651f authored by hjk's avatar hjk

Show summary when using -profile command line option

Change-Id: Ieeec4be993b1c53a59407349d365a6aaf1a92e32
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
parent ec1d0811
......@@ -837,6 +837,7 @@ void PluginManagerPrivate::nextDelayedInitialize()
if (delayedInitializeQueue.isEmpty()) {
delete delayedInitializeTimer;
delayedInitializeTimer = 0;
profilingSummary();
emit q->initializationDone();
} else {
delayedInitializeTimer->start();
......@@ -1308,6 +1309,7 @@ void PluginManagerPrivate::profilingReport(const char *what, const PluginSpec *s
const int absoluteElapsedMS = m_profileTimer->elapsed();
const int elapsedMS = absoluteElapsedMS - m_profileElapsedMS;
m_profileElapsedMS = absoluteElapsedMS;
m_profileTotal[spec] += elapsedMS;
if (spec)
qDebug("%-22s %-22s %8dms (%8dms)", what, qPrintable(spec->name()), absoluteElapsedMS, elapsedMS);
else
......@@ -1315,6 +1317,24 @@ void PluginManagerPrivate::profilingReport(const char *what, const PluginSpec *s
}
}
void PluginManagerPrivate::profilingSummary() const
{
if (!m_profileTimer.isNull()) {
typedef QMultiMap<int, const PluginSpec *> Sorter;
Sorter sorter;
QHash<const PluginSpec *, int>::ConstIterator it1 = m_profileTotal.constBegin();
QHash<const PluginSpec *, int>::ConstIterator et1 = m_profileTotal.constEnd();
for (; it1 != et1; ++it1)
sorter.insert(it1.value(), it1.key());
Sorter::ConstIterator it2 = sorter.begin();
Sorter::ConstIterator et2 = sorter.end();
for (; it2 != et2; ++it2)
qDebug("%-22s %8dms", qPrintable(it2.value()->name()), it2.key());
}
}
/*!
\fn void PluginManager::getObjectByName(const QString &name) const
\brief Retrieves one object with a given name from the object pool.
......
......@@ -72,6 +72,7 @@ public:
void loadPlugin(PluginSpec *spec, PluginSpec::State destState);
void resolveDependencies();
void initProfiling();
void profilingSummary() const;
void profilingReport(const char *what, const PluginSpec *spec = 0);
void setSettings(QSettings *settings);
void setGlobalSettings(QSettings *settings);
......@@ -114,6 +115,7 @@ public:
QStringList arguments;
QScopedPointer<QTime> m_profileTimer;
QHash<const PluginSpec *, int> m_profileTotal;
int m_profileElapsedMS;
unsigned m_profilingVerbosity;
QSettings *settings;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment