diff --git a/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp index a527551969f..cd96b971ce6 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp +++ b/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp @@ -211,6 +211,7 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd) QmlEventStats *stats = &d->data[event->typeIndex()]; stats->duration += event->duration(); + stats->durationSelf += event->duration(); if (event->duration() < stats->minTime) stats->minTime = event->duration(); if (event->duration() > stats->maxTime) @@ -226,7 +227,6 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd) lastEndTime = event->startTime() + event->duration(); } - // // binding loop detection // @@ -245,6 +245,8 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd) } } + if (callStack.count() > 1) + d->data[callStack.top()->typeIndex()].durationSelf -= event->duration(); callStack.push(event); d->modelManager->modelProxyCountUpdated(d->modelId, i, eventList.count()*2); @@ -266,6 +268,7 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd) } stats->percentOfTime = stats->duration * 100.0 / qmlTime; + stats->percentSelf = stats->durationSelf * 100.0 / qmlTime; d->modelManager->modelProxyCountUpdated(d->modelId, i++, total); } @@ -277,8 +280,10 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd) QmlEventStats rootEvent; rootEvent.duration = rootEvent.minTime = rootEvent.maxTime = rootEvent.timePerCall = rootEvent.medianTime = qmlTime + 1; + rootEvent.durationSelf = 1; rootEvent.calls = 1; rootEvent.percentOfTime = 100.0; + rootEvent.percentSelf = 1.0 / rootEvent.duration; d->data.insert(-1, rootEvent); diff --git a/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.h b/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.h index f98f8ea5ec0..d89e4dc417a 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.h +++ b/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.h @@ -51,14 +51,17 @@ class QmlProfilerEventsModelProxy : public QObject Q_OBJECT public: struct QmlEventStats { - QmlEventStats() : duration(0), calls(0), minTime(std::numeric_limits::max()), - maxTime(0), timePerCall(0), percentOfTime(0), medianTime(0), isBindingLoop(false) {} + QmlEventStats() : duration(0), durationSelf(0), calls(0), + minTime(std::numeric_limits::max()), maxTime(0), timePerCall(0), + percentOfTime(0), percentSelf(0), medianTime(0), isBindingLoop(false) {} qint64 duration; + qint64 durationSelf; qint64 calls; qint64 minTime; qint64 maxTime; qint64 timePerCall; double percentOfTime; + double percentSelf; qint64 medianTime; bool isBindingLoop; diff --git a/src/plugins/qmlprofiler/qmlprofilereventview.cpp b/src/plugins/qmlprofiler/qmlprofilereventview.cpp index 7cc3d205867..cba72b1b576 100644 --- a/src/plugins/qmlprofiler/qmlprofilereventview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilereventview.cpp @@ -432,8 +432,8 @@ QmlProfilerEventsMainView::QmlProfilerEventsMainView(QWidget *parent, setFieldViewable(Type, true); setFieldViewable(TimeInPercent, true); setFieldViewable(TotalTime, true); - setFieldViewable(SelfTimeInPercent, false); - setFieldViewable(SelfTime, false); + setFieldViewable(SelfTimeInPercent, true); + setFieldViewable(SelfTime, true); setFieldViewable(CallCount, true); setFieldViewable(TimePerCall, true); setFieldViewable(MaxTime, true); @@ -663,6 +663,17 @@ void QmlProfilerEventsMainView::parseModelProxy() newRow.last()->setData(QVariant(stats.duration)); } + if (d->m_fieldShown[SelfTimeInPercent]) { + newRow << new EventsViewItem(QString::number(stats.percentSelf, 'f', 2) + + QLatin1String(" %")); + newRow.last()->setData(QVariant(stats.percentSelf)); + } + + if (d->m_fieldShown[SelfTime]) { + newRow << new EventsViewItem(QmlProfilerDataModel::formatTime(stats.durationSelf)); + newRow.last()->setData(QVariant(stats.durationSelf)); + } + if (d->m_fieldShown[CallCount]) { newRow << new EventsViewItem(QString::number(stats.calls)); newRow.last()->setData(QVariant(stats.calls));