Commit b6fb8bba authored by Friedemann Kleint's avatar Friedemann Kleint

Pluginmanager: Make startup profiling API accessible.A

Add verbosity option showing timestamps for PluginManager::addObject.
parent 259007f5
......@@ -574,6 +574,17 @@ QString PluginManager::testDataDirectory() const
return s;
}
/*!
\fn void PluginManager::profilingReport(const char *what, const PluginSpec *spec = 0)
Create a profiling entry showing the elapsed time if profiling is activated.
*/
void PluginManager::profilingReport(const char *what, const PluginSpec *spec)
{
d->profilingReport(what, spec);
}
//============PluginManagerPrivate===========
/*!
......@@ -601,6 +612,7 @@ PluginSpecPrivate *PluginManagerPrivate::privateSpec(PluginSpec *spec)
PluginManagerPrivate::PluginManagerPrivate(PluginManager *pluginManager) :
extension(QLatin1String("xml")),
m_profileElapsedMS(0),
m_profilingVerbosity(0),
q(pluginManager)
{
}
......@@ -679,6 +691,13 @@ void PluginManagerPrivate::addObject(QObject *obj)
if (debugLeaks)
qDebug() << "PluginManagerPrivate::addObject" << obj << obj->objectName();
if (m_profilingVerbosity && !m_profileTimer.isNull()) {
// Report a timestamp when adding an object. Useful for profiling
// its initialization time.
const int absoluteElapsedMS = m_profileTimer->elapsed();
qDebug(" %-43s %8dms", obj->metaObject()->className(), absoluteElapsedMS);
}
allObjects.append(obj);
}
emit q->objectAdded(obj);
......@@ -964,6 +983,8 @@ void PluginManagerPrivate::initProfiling()
m_profileTimer->start();
m_profileElapsedMS = 0;
qDebug("Profiling started");
} else {
m_profilingVerbosity++;
}
}
......@@ -976,7 +997,7 @@ void PluginManagerPrivate::profilingReport(const char *what, const PluginSpec *s
if (spec) {
qDebug("%-22s %-22s %8dms (%8dms)", what, qPrintable(spec->name()), absoluteElapsedMS, elapsedMS);
} else {
qDebug("%-22s %8dms (%8dms)", what, absoluteElapsedMS, elapsedMS);
qDebug("%-45s %8dms (%8dms)", what, absoluteElapsedMS, elapsedMS);
}
}
}
......@@ -118,6 +118,8 @@ public:
bool runningTests() const;
QString testDataDirectory() const;
void profilingReport(const char *what, const PluginSpec *spec = 0);
signals:
void objectAdded(QObject *obj);
void aboutToRemoveObject(QObject *obj);
......
......@@ -85,6 +85,7 @@ public:
QStringList arguments;
QScopedPointer<QTime> m_profileTimer;
int m_profileElapsedMS;
unsigned m_profilingVerbosity;
// Look in argument descriptions of the specs for the option.
PluginSpec *pluginForOption(const QString &option, bool *requiresArgument) const;
......
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