forked from qt-creator/qt-creator
Pluginmanager: Make startup profiling API accessible.A
Add verbosity option showing timestamps for PluginManager::addObject.
This commit is contained in:
@@ -574,6 +574,17 @@ QString PluginManager::testDataDirectory() const
|
|||||||
return s;
|
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===========
|
//============PluginManagerPrivate===========
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -601,6 +612,7 @@ PluginSpecPrivate *PluginManagerPrivate::privateSpec(PluginSpec *spec)
|
|||||||
PluginManagerPrivate::PluginManagerPrivate(PluginManager *pluginManager) :
|
PluginManagerPrivate::PluginManagerPrivate(PluginManager *pluginManager) :
|
||||||
extension(QLatin1String("xml")),
|
extension(QLatin1String("xml")),
|
||||||
m_profileElapsedMS(0),
|
m_profileElapsedMS(0),
|
||||||
|
m_profilingVerbosity(0),
|
||||||
q(pluginManager)
|
q(pluginManager)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -679,6 +691,13 @@ void PluginManagerPrivate::addObject(QObject *obj)
|
|||||||
if (debugLeaks)
|
if (debugLeaks)
|
||||||
qDebug() << "PluginManagerPrivate::addObject" << obj << obj->objectName();
|
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);
|
allObjects.append(obj);
|
||||||
}
|
}
|
||||||
emit q->objectAdded(obj);
|
emit q->objectAdded(obj);
|
||||||
@@ -964,6 +983,8 @@ void PluginManagerPrivate::initProfiling()
|
|||||||
m_profileTimer->start();
|
m_profileTimer->start();
|
||||||
m_profileElapsedMS = 0;
|
m_profileElapsedMS = 0;
|
||||||
qDebug("Profiling started");
|
qDebug("Profiling started");
|
||||||
|
} else {
|
||||||
|
m_profilingVerbosity++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,7 +997,7 @@ void PluginManagerPrivate::profilingReport(const char *what, const PluginSpec *s
|
|||||||
if (spec) {
|
if (spec) {
|
||||||
qDebug("%-22s %-22s %8dms (%8dms)", what, qPrintable(spec->name()), absoluteElapsedMS, elapsedMS);
|
qDebug("%-22s %-22s %8dms (%8dms)", what, qPrintable(spec->name()), absoluteElapsedMS, elapsedMS);
|
||||||
} else {
|
} else {
|
||||||
qDebug("%-22s %8dms (%8dms)", what, absoluteElapsedMS, elapsedMS);
|
qDebug("%-45s %8dms (%8dms)", what, absoluteElapsedMS, elapsedMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,6 +118,8 @@ public:
|
|||||||
bool runningTests() const;
|
bool runningTests() const;
|
||||||
QString testDataDirectory() const;
|
QString testDataDirectory() const;
|
||||||
|
|
||||||
|
void profilingReport(const char *what, const PluginSpec *spec = 0);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void objectAdded(QObject *obj);
|
void objectAdded(QObject *obj);
|
||||||
void aboutToRemoveObject(QObject *obj);
|
void aboutToRemoveObject(QObject *obj);
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ public:
|
|||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
QScopedPointer<QTime> m_profileTimer;
|
QScopedPointer<QTime> m_profileTimer;
|
||||||
int m_profileElapsedMS;
|
int m_profileElapsedMS;
|
||||||
|
unsigned m_profilingVerbosity;
|
||||||
|
|
||||||
// Look in argument descriptions of the specs for the option.
|
// Look in argument descriptions of the specs for the option.
|
||||||
PluginSpec *pluginForOption(const QString &option, bool *requiresArgument) const;
|
PluginSpec *pluginForOption(const QString &option, bool *requiresArgument) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user