forked from qt-creator/qt-creator
QmlProfiler: Make the progress bar somewhat nicer.
Allow adding a weight to certain tasks so that the movement of the bar gets smoother and update the progress from more places. Change-Id: Ifb8331dc77116cc0464b3970cd6344fbbeacec41 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -69,6 +69,9 @@ QmlProfilerEventsModelProxy::QmlProfilerEventsModelProxy(QmlProfilerModelManager
|
|||||||
connect(modelManager->simpleModel(), SIGNAL(changed()), this, SLOT(dataChanged()));
|
connect(modelManager->simpleModel(), SIGNAL(changed()), this, SLOT(dataChanged()));
|
||||||
d->modelId = modelManager->registerModelProxy();
|
d->modelId = modelManager->registerModelProxy();
|
||||||
|
|
||||||
|
// We're iterating twice in loadData.
|
||||||
|
modelManager->setProxyCountWeight(d->modelId, 2);
|
||||||
|
|
||||||
d->acceptedTypes << QmlDebug::Compiling << QmlDebug::Creating << QmlDebug::Binding << QmlDebug::HandlingSignal << QmlDebug::Javascript;
|
d->acceptedTypes << QmlDebug::Compiling << QmlDebug::Creating << QmlDebug::Binding << QmlDebug::HandlingSignal << QmlDebug::Javascript;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,6 +214,8 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// post-process: calc mean time, median time, percentoftime
|
// post-process: calc mean time, median time, percentoftime
|
||||||
|
int i = d->data.size();
|
||||||
|
int total = i * 2;
|
||||||
foreach (const QString &hash, d->data.keys()) {
|
foreach (const QString &hash, d->data.keys()) {
|
||||||
QmlEventStats* stats = &d->data[hash];
|
QmlEventStats* stats = &d->data[hash];
|
||||||
if (stats->calls > 0)
|
if (stats->calls > 0)
|
||||||
@@ -223,6 +228,7 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
stats->percentOfTime = stats->duration * 100.0 / qmlTime;
|
stats->percentOfTime = stats->duration * 100.0 / qmlTime;
|
||||||
|
d->modelManager->modelProxyCountUpdated(d->modelId, i++, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set binding loop flag
|
// set binding loop flag
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ public:
|
|||||||
QmlProfilerTraceTime *traceTime;
|
QmlProfilerTraceTime *traceTime;
|
||||||
|
|
||||||
QVector <double> partialCounts;
|
QVector <double> partialCounts;
|
||||||
|
QVector <int> partialCountWeights;
|
||||||
|
int totalWeight;
|
||||||
double progress;
|
double progress;
|
||||||
qint64 estimatedTime;
|
qint64 estimatedTime;
|
||||||
|
|
||||||
@@ -156,6 +158,7 @@ public:
|
|||||||
QmlProfilerModelManager::QmlProfilerModelManager(Utils::FileInProjectFinder *finder, QObject *parent) :
|
QmlProfilerModelManager::QmlProfilerModelManager(Utils::FileInProjectFinder *finder, QObject *parent) :
|
||||||
QObject(parent), d(new QmlProfilerModelManagerPrivate(this))
|
QObject(parent), d(new QmlProfilerModelManagerPrivate(this))
|
||||||
{
|
{
|
||||||
|
d->totalWeight = 0;
|
||||||
d->model = new QmlProfilerProcessedModel(finder, this);
|
d->model = new QmlProfilerProcessedModel(finder, this);
|
||||||
d->v8Model = new QV8ProfilerDataModel(this);
|
d->v8Model = new QV8ProfilerDataModel(this);
|
||||||
// d->model = new QmlProfilerSimpleModel(this);
|
// d->model = new QmlProfilerSimpleModel(this);
|
||||||
@@ -201,20 +204,29 @@ double QmlProfilerModelManager::progress() const
|
|||||||
int QmlProfilerModelManager::registerModelProxy()
|
int QmlProfilerModelManager::registerModelProxy()
|
||||||
{
|
{
|
||||||
d->partialCounts << 0;
|
d->partialCounts << 0;
|
||||||
|
d->partialCountWeights << 1;
|
||||||
|
d->totalWeight++;
|
||||||
return d->partialCounts.count()-1;
|
return d->partialCounts.count()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlProfilerModelManager::setProxyCountWeight(int proxyId, int weight)
|
||||||
|
{
|
||||||
|
d->totalWeight += weight - d->partialCountWeights[proxyId];
|
||||||
|
d->partialCountWeights[proxyId] = weight;
|
||||||
|
}
|
||||||
|
|
||||||
void QmlProfilerModelManager::modelProxyCountUpdated(int proxyId, qint64 count, qint64 max)
|
void QmlProfilerModelManager::modelProxyCountUpdated(int proxyId, qint64 count, qint64 max)
|
||||||
{
|
{
|
||||||
d->progress -= d->partialCounts[proxyId] / d->partialCounts.count();
|
d->progress -= d->partialCounts[proxyId] * d->partialCountWeights[proxyId] /
|
||||||
|
d->totalWeight;
|
||||||
|
|
||||||
if (max <= 0)
|
if (max <= 0)
|
||||||
d->partialCounts[proxyId] = 1;
|
d->partialCounts[proxyId] = 1;
|
||||||
else
|
else
|
||||||
d->partialCounts[proxyId] = (double)count / (double) max;
|
d->partialCounts[proxyId] = (double)count / (double) max;
|
||||||
|
|
||||||
d->progress += d->partialCounts[proxyId] / d->partialCounts.count();
|
d->progress += d->partialCounts[proxyId] * d->partialCountWeights[proxyId] /
|
||||||
|
d->totalWeight;
|
||||||
emit progressChanged();
|
emit progressChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ public:
|
|||||||
|
|
||||||
double progress() const;
|
double progress() const;
|
||||||
int registerModelProxy();
|
int registerModelProxy();
|
||||||
|
void setProxyCountWeight(int proxyId, int weight);
|
||||||
void modelProxyCountUpdated(int proxyId, qint64 count, qint64 max);
|
void modelProxyCountUpdated(int proxyId, qint64 count, qint64 max);
|
||||||
|
|
||||||
qint64 estimatedProfilingTime() const;
|
qint64 estimatedProfilingTime() const;
|
||||||
|
|||||||
@@ -101,6 +101,10 @@ QmlProfilerProcessedModel::QmlProfilerProcessedModel(Utils::FileInProjectFinder
|
|||||||
: QmlProfilerSimpleModel(parent)
|
: QmlProfilerSimpleModel(parent)
|
||||||
, m_detailsRewriter(new QmlProfilerDetailsRewriter(this, fileFinder))
|
, m_detailsRewriter(new QmlProfilerDetailsRewriter(this, fileFinder))
|
||||||
{
|
{
|
||||||
|
m_processedModelId = m_modelManager->registerModelProxy();
|
||||||
|
// The document loading is very expensive.
|
||||||
|
m_modelManager->setProxyCountWeight(m_processedModelId, 3);
|
||||||
|
|
||||||
connect(m_detailsRewriter, SIGNAL(rewriteDetailsString(int,QString)),
|
connect(m_detailsRewriter, SIGNAL(rewriteDetailsString(int,QString)),
|
||||||
this, SLOT(detailsChanged(int,QString)));
|
this, SLOT(detailsChanged(int,QString)));
|
||||||
connect(m_detailsRewriter, SIGNAL(eventDetailsChanged()),
|
connect(m_detailsRewriter, SIGNAL(eventDetailsChanged()),
|
||||||
@@ -114,13 +118,14 @@ QmlProfilerProcessedModel::~QmlProfilerProcessedModel()
|
|||||||
void QmlProfilerProcessedModel::clear()
|
void QmlProfilerProcessedModel::clear()
|
||||||
{
|
{
|
||||||
m_detailsRewriter->clearRequests();
|
m_detailsRewriter->clearRequests();
|
||||||
|
m_modelManager->modelProxyCountUpdated(m_processedModelId, 0, 1);
|
||||||
// This call emits changed(). Don't emit it again here.
|
// This call emits changed(). Don't emit it again here.
|
||||||
QmlProfilerSimpleModel::clear();
|
QmlProfilerSimpleModel::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerProcessedModel::complete()
|
void QmlProfilerProcessedModel::complete()
|
||||||
{
|
{
|
||||||
|
m_modelManager->modelProxyCountUpdated(m_processedModelId, 0, 1);
|
||||||
// post-processing
|
// post-processing
|
||||||
|
|
||||||
// sort events by start time
|
// sort events by start time
|
||||||
@@ -150,6 +155,7 @@ void QmlProfilerProcessedModel::complete()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
m_detailsRewriter->requestDetailsForLocation(i, event->location);
|
m_detailsRewriter->requestDetailsForLocation(i, event->location);
|
||||||
|
m_modelManager->modelProxyCountUpdated(m_processedModelId, i, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow QmlProfilerBaseModel::complete() only after documents have been reloaded to avoid
|
// Allow QmlProfilerBaseModel::complete() only after documents have been reloaded to avoid
|
||||||
@@ -167,6 +173,7 @@ void QmlProfilerProcessedModel::detailsChanged(int requestId, const QString &new
|
|||||||
|
|
||||||
void QmlProfilerProcessedModel::detailsDone()
|
void QmlProfilerProcessedModel::detailsDone()
|
||||||
{
|
{
|
||||||
|
m_modelManager->modelProxyCountUpdated(m_processedModelId, 1, 1);
|
||||||
// The child models are supposed to synchronously update on changed(), triggered by
|
// The child models are supposed to synchronously update on changed(), triggered by
|
||||||
// QmlProfilerBaseModel::complete().
|
// QmlProfilerBaseModel::complete().
|
||||||
QmlProfilerSimpleModel::complete();
|
QmlProfilerSimpleModel::complete();
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ private slots:
|
|||||||
void detailsDone();
|
void detailsDone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int m_processedModelId;
|
||||||
QmlProfilerDetailsRewriter *m_detailsRewriter;
|
QmlProfilerDetailsRewriter *m_detailsRewriter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ namespace QmlProfiler {
|
|||||||
QmlProfilerSimpleModel::QmlProfilerSimpleModel(QmlProfilerModelManager *parent)
|
QmlProfilerSimpleModel::QmlProfilerSimpleModel(QmlProfilerModelManager *parent)
|
||||||
: QmlProfilerBaseModel(parent)
|
: QmlProfilerBaseModel(parent)
|
||||||
{
|
{
|
||||||
|
m_modelManager->setProxyCountWeight(m_modelId, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerSimpleModel::~QmlProfilerSimpleModel()
|
QmlProfilerSimpleModel::~QmlProfilerSimpleModel()
|
||||||
|
|||||||
Reference in New Issue
Block a user