QmlProfiler: Unify QML and V8 data models

There is no real reason for the existence of a QmlProfilerSimpleModel.

Change-Id: I6419973cfad5564913bf92f17fdcf7e529af4b01
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-02-18 17:32:20 +01:00
parent 133199a033
commit 58e3c9ed05
29 changed files with 246 additions and 403 deletions

View File

@@ -53,7 +53,7 @@ void AbstractTimelineModel::setModelManager(QmlProfilerModelManager *modelManage
{
Q_D(AbstractTimelineModel);
d->modelManager = modelManager;
connect(d->modelManager->simpleModel(),SIGNAL(changed()),this,SLOT(dataChanged()));
connect(d->modelManager->qmlModel(),SIGNAL(changed()),this,SLOT(dataChanged()));
d->modelId = d->modelManager->registerModelProxy();
}

View File

@@ -33,7 +33,7 @@
#include "qmlprofiler_global.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilersimplemodel.h"
#include "qmlprofilerdatamodel.h"
#include <QObject>
#include <QVariant>
#include <QColor>
@@ -79,7 +79,7 @@ public:
Q_INVOKABLE virtual QColor getColor(int index) const = 0;
Q_INVOKABLE virtual const QVariantList getLabelsForCategory(int category) const = 0;
Q_INVOKABLE virtual const QVariantList getEventDetails(int index) const = 0;
virtual bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const = 0;
virtual bool eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const = 0;
virtual int getEventType(int index) const = 0;
virtual int getEventCategory(int index) const = 0;
virtual int getEventRow(int index) const = 0;

View File

@@ -22,8 +22,6 @@ SOURCES += \
qmlprofilerstatewidget.cpp \
qmlprofilerruncontrolfactory.cpp \
qmlprofilermodelmanager.cpp \
qmlprofilersimplemodel.cpp \
qmlprofilerprocessedmodel.cpp \
qmlprofilereventsmodelproxy.cpp \
qmlprofilertimelinemodelproxy.cpp \
qmlprofilertreeview.cpp \
@@ -33,7 +31,8 @@ SOURCES += \
qmlprofilerpainteventsmodelproxy.cpp \
sortedtimelinemodel.cpp \
qmlprofilerbasemodel.cpp \
singlecategorytimelinemodel.cpp
singlecategorytimelinemodel.cpp \
qmlprofilerdatamodel.cpp
HEADERS += \
qmlprofilerconstants.h \
@@ -56,8 +55,6 @@ HEADERS += \
qmlprofilerstatewidget.h \
qmlprofilerruncontrolfactory.h \
qmlprofilermodelmanager.h \
qmlprofilersimplemodel.h \
qmlprofilerprocessedmodel.h \
qmlprofilereventsmodelproxy.h \
qmlprofilertimelinemodelproxy.h \
qmlprofilertreeview.h \
@@ -69,7 +66,8 @@ HEADERS += \
qmlprofilerbasemodel.h \
abstracttimelinemodel_p.h \
singlecategorytimelinemodel.h \
singlecategorytimelinemodel_p.h
singlecategorytimelinemodel_p.h \
qmlprofilerdatamodel.h
RESOURCES += \
qml/qmlprofiler.qrc

View File

@@ -31,6 +31,7 @@ QtcPlugin {
"qmlprofilerbasemodel.cpp", "qmlprofilerbasemodel.h",
"qmlprofilerclientmanager.cpp", "qmlprofilerclientmanager.h",
"qmlprofilerconstants.h",
"qmlprofilerdatamodel.cpp", "qmlprofilerdatamodel.h",
"qmlprofilerdetailsrewriter.cpp", "qmlprofilerdetailsrewriter.h",
"qmlprofilerengine.cpp", "qmlprofilerengine.h",
"qmlprofilereventsmodelproxy.cpp", "qmlprofilereventsmodelproxy.h",
@@ -38,9 +39,7 @@ QtcPlugin {
"qmlprofilermodelmanager.cpp", "qmlprofilermodelmanager.h",
"qmlprofilerpainteventsmodelproxy.h", "qmlprofilerpainteventsmodelproxy.cpp",
"qmlprofilerplugin.cpp", "qmlprofilerplugin.h",
"qmlprofilerprocessedmodel.cpp", "qmlprofilerprocessedmodel.h",
"qmlprofilerruncontrolfactory.cpp", "qmlprofilerruncontrolfactory.h",
"qmlprofilersimplemodel.cpp", "qmlprofilersimplemodel.h",
"qmlprofilerstatemanager.cpp", "qmlprofilerstatemanager.h",
"qmlprofilerstatewidget.cpp", "qmlprofilerstatewidget.h",
"qmlprofilertimelinemodelproxy.cpp", "qmlprofilertimelinemodelproxy.h",

View File

@@ -32,21 +32,42 @@
namespace QmlProfiler {
QmlProfilerBaseModel::QmlProfilerBaseModel(QmlProfilerModelManager *manager) :
m_modelManager(manager), m_processingDone(false)
QmlProfilerBaseModel::QmlProfilerBaseModel(Utils::FileInProjectFinder *fileFinder,
QmlProfilerModelManager *manager) :
m_modelManager(manager), m_processingDone(false), m_detailsRewriter(this, fileFinder)
{
Q_ASSERT(m_modelManager);
m_modelId = m_modelManager->registerModelProxy();
connect(&m_detailsRewriter, SIGNAL(rewriteDetailsString(int,QString)),
this, SLOT(detailsChanged(int,QString)));
connect(&m_detailsRewriter, SIGNAL(eventDetailsChanged()),
this, SLOT(detailsDone()));
}
void QmlProfilerBaseModel::clear()
{
m_detailsRewriter.clearRequests();
m_modelManager->modelProxyCountUpdated(m_modelId, 0, 1);
m_processingDone = false;
emit changed();
}
void QmlProfilerBaseModel::complete()
{
m_detailsRewriter.reloadDocuments();
}
QString QmlProfilerBaseModel::formatTime(qint64 timestamp)
{
if (timestamp < 1e6)
return QString::number(timestamp/1e3f,'f',3) + trUtf8(" \xc2\xb5s");
if (timestamp < 1e9)
return QString::number(timestamp/1e6f,'f',3) + tr(" ms");
return QString::number(timestamp/1e9f,'f',3) + tr(" s");
}
void QmlProfilerBaseModel::detailsDone()
{
emit changed();
m_processingDone = true;

View File

@@ -31,6 +31,7 @@
#define QMLPROFILERBASEMODEL_H
#include "qmlprofiler_global.h"
#include "qmlprofilerdetailsrewriter.h"
#include <QObject>
namespace QmlProfiler {
@@ -40,7 +41,7 @@ class QmlProfilerModelManager;
class QMLPROFILER_EXPORT QmlProfilerBaseModel : public QObject {
Q_OBJECT
public:
QmlProfilerBaseModel(QmlProfilerModelManager *manager);
QmlProfilerBaseModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *manager);
virtual ~QmlProfilerBaseModel() {}
virtual void complete();
@@ -48,10 +49,17 @@ public:
virtual bool isEmpty() const = 0;
bool processingDone() const { return m_processingDone; }
static QString formatTime(qint64 timestamp);
protected:
QmlProfilerModelManager *m_modelManager;
int m_modelId;
bool m_processingDone;
Internal::QmlProfilerDetailsRewriter m_detailsRewriter;
protected slots:
virtual void detailsChanged(int requestId, const QString &newString) = 0;
virtual void detailsDone();
signals:
void changed();

View File

@@ -27,7 +27,7 @@
**
****************************************************************************/
#include "qmlprofilerprocessedmodel.h"
#include "qmlprofilerdatamodel.h"
#include "qmlprofilermodelmanager.h"
#include <qmldebug/qmlprofilereventtypes.h>
#include <utils/qtcassert.h>
@@ -35,13 +35,12 @@
#include <QDebug>
namespace QmlProfiler {
namespace Internal {
QmlDebug::QmlEventLocation getLocation(const QmlProfilerSimpleModel::QmlEventData &event);
QString getDisplayName(const QmlProfilerSimpleModel::QmlEventData &event);
QString getInitialDetails(const QmlProfilerSimpleModel::QmlEventData &event);
QmlDebug::QmlEventLocation getLocation(const QmlProfilerDataModel::QmlEventData &event);
QString getDisplayName(const QmlProfilerDataModel::QmlEventData &event);
QString getInitialDetails(const QmlProfilerDataModel::QmlEventData &event);
QmlDebug::QmlEventLocation getLocation(const QmlProfilerSimpleModel::QmlEventData &event)
QmlDebug::QmlEventLocation getLocation(const QmlProfilerDataModel::QmlEventData &event)
{
QmlDebug::QmlEventLocation eventLocation = event.location;
if ((event.eventType == QmlDebug::Creating || event.eventType == QmlDebug::Compiling)
@@ -53,14 +52,14 @@ QmlDebug::QmlEventLocation getLocation(const QmlProfilerSimpleModel::QmlEventDat
return eventLocation;
}
QString getDisplayName(const QmlProfilerSimpleModel::QmlEventData &event)
QString getDisplayName(const QmlProfilerDataModel::QmlEventData &event)
{
const QmlDebug::QmlEventLocation eventLocation = getLocation(event);
QString displayName;
// generate hash
if (eventLocation.filename.isEmpty()) {
displayName = QmlProfilerProcessedModel::tr("<bytecode>");
displayName = QmlProfilerDataModel::tr("<bytecode>");
} else {
const QString filePath = QUrl(eventLocation.filename).path();
displayName = filePath.mid(filePath.lastIndexOf(QLatin1Char('/')) + 1) + QLatin1Char(':') +
@@ -70,16 +69,16 @@ QString getDisplayName(const QmlProfilerSimpleModel::QmlEventData &event)
return displayName;
}
QString getInitialDetails(const QmlProfilerSimpleModel::QmlEventData &event)
QString getInitialDetails(const QmlProfilerDataModel::QmlEventData &event)
{
QString details;
// generate details string
if (event.data.isEmpty())
details = QmlProfilerProcessedModel::tr("Source code not available.");
details = QmlProfilerDataModel::tr("Source code not available.");
else {
details = event.data.join(QLatin1String(" ")).replace(QLatin1Char('\n'),QLatin1Char(' ')).simplified();
if (details.isEmpty()) {
details = QmlProfilerProcessedModel::tr("anonymous function");
details = QmlProfilerDataModel::tr("anonymous function");
} else {
QRegExp rewrite(QLatin1String("\\(function \\$(\\w+)\\(\\) \\{ (return |)(.+) \\}\\)"));
bool match = rewrite.exactMatch(details);
@@ -94,51 +93,54 @@ QString getInitialDetails(const QmlProfilerSimpleModel::QmlEventData &event)
}
bool compareStartTimes(const QmlProfilerSimpleModel::QmlEventData &t1, const QmlProfilerSimpleModel::QmlEventData &t2)
bool compareStartTimes(const QmlProfilerDataModel::QmlEventData &t1, const QmlProfilerDataModel::QmlEventData &t2)
{
return t1.startTime < t2.startTime;
}
//////////////////////////////////////////////////////////////////////////////
QmlProfilerProcessedModel::QmlProfilerProcessedModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent)
: QmlProfilerSimpleModel(parent)
, m_detailsRewriter(new QmlProfilerDetailsRewriter(this, fileFinder))
QmlProfilerDataModel::QmlProfilerDataModel(Utils::FileInProjectFinder *fileFinder,
QmlProfilerModelManager *parent)
: QmlProfilerBaseModel(fileFinder, parent)
{
m_processedModelId = m_modelManager->registerModelProxy();
// The document loading is very expensive.
m_modelManager->setProxyCountWeight(m_processedModelId, 3);
connect(m_detailsRewriter, SIGNAL(rewriteDetailsString(int,QString)),
this, SLOT(detailsChanged(int,QString)));
connect(m_detailsRewriter, SIGNAL(eventDetailsChanged()),
this, SLOT(detailsDone()));
m_modelManager->setProxyCountWeight(m_modelId, 4);
}
QmlProfilerProcessedModel::~QmlProfilerProcessedModel()
const QVector<QmlProfilerDataModel::QmlEventData> &QmlProfilerDataModel::getEvents() const
{
return m_eventList;
}
void QmlProfilerProcessedModel::clear()
int QmlProfilerDataModel::count() const
{
m_detailsRewriter->clearRequests();
m_modelManager->modelProxyCountUpdated(m_processedModelId, 0, 1);
return m_eventList.count();
}
void QmlProfilerDataModel::clear()
{
m_eventList.clear();
// This call emits changed(). Don't emit it again here.
QmlProfilerSimpleModel::clear();
QmlProfilerBaseModel::clear();
}
void QmlProfilerProcessedModel::complete()
bool QmlProfilerDataModel::isEmpty() const
{
return m_eventList.isEmpty();
}
void QmlProfilerDataModel::complete()
{
m_modelManager->modelProxyCountUpdated(m_processedModelId, 0, 1);
// post-processing
// sort events by start time
qSort(eventList.begin(), eventList.end(), compareStartTimes);
qSort(m_eventList.begin(), m_eventList.end(), compareStartTimes);
// rewrite strings
int n = eventList.count();
int n = m_eventList.count();
for (int i = 0; i < n; i++) {
QmlEventData *event = &eventList[i];
QmlEventData *event = &m_eventList[i];
event->location = getLocation(*event);
event->displayName = getDisplayName(*event);
event->data = QStringList() << getInitialDetails(*event);
@@ -158,30 +160,62 @@ void QmlProfilerProcessedModel::complete()
if (event->location.column == -1)
continue;
m_detailsRewriter->requestDetailsForLocation(i, event->location);
m_modelManager->modelProxyCountUpdated(m_processedModelId, i, n);
m_detailsRewriter.requestDetailsForLocation(i, event->location);
m_modelManager->modelProxyCountUpdated(m_modelId, i + n, n * 2);
}
// Allow QmlProfilerBaseModel::complete() only after documents have been reloaded to avoid
// Allow changed() event only after documents have been reloaded to avoid
// unnecessary updates of child models.
m_detailsRewriter->reloadDocuments();
QmlProfilerBaseModel::complete();
}
void QmlProfilerProcessedModel::detailsChanged(int requestId, const QString &newString)
void QmlProfilerDataModel::addQmlEvent(int type, int bindingType, qint64 startTime,
qint64 duration, const QStringList &data,
const QmlDebug::QmlEventLocation &location,
qint64 ndata1, qint64 ndata2, qint64 ndata3,
qint64 ndata4, qint64 ndata5)
{
QTC_ASSERT(requestId < eventList.count(), return);
QString displayName;
if (type == QmlDebug::Painting && bindingType == QmlDebug::AnimationFrame) {
displayName = tr("Animations");
} else {
displayName = QString::fromLatin1("%1:%2").arg(
location.filename,
QString::number(location.line));
}
QmlEventData *event = &eventList[requestId];
QmlEventData eventData = {displayName, type, bindingType, startTime, duration, data, location,
ndata1, ndata2, ndata3, ndata4, ndata5};
m_eventList.append(eventData);
m_modelManager->modelProxyCountUpdated(m_modelId, startTime,
m_modelManager->estimatedProfilingTime() * 2);
}
QString QmlProfilerDataModel::getHashString(const QmlProfilerDataModel::QmlEventData &event)
{
return QString::fromLatin1("%1:%2:%3:%4:%5").arg(
event.location.filename,
QString::number(event.location.line),
QString::number(event.location.column),
QString::number(event.eventType),
QString::number(event.bindingType));
}
qint64 QmlProfilerDataModel::lastTimeMark() const
{
if (m_eventList.isEmpty())
return 0;
return m_eventList.last().startTime + m_eventList.last().duration;
}
void QmlProfilerDataModel::detailsChanged(int requestId, const QString &newString)
{
QTC_ASSERT(requestId < m_eventList.count(), return);
QmlEventData *event = &m_eventList[requestId];
event->data = QStringList(newString);
}
void QmlProfilerProcessedModel::detailsDone()
{
m_modelManager->modelProxyCountUpdated(m_processedModelId, 1, 1);
// The child models are supposed to synchronously update on changed(), triggered by
// QmlProfilerBaseModel::complete().
QmlProfilerSimpleModel::complete();
}
}
}

View File

@@ -27,24 +27,14 @@
**
****************************************************************************/
#ifndef QMLPROFILERSIMPLEMODEL_H
#define QMLPROFILERSIMPLEMODEL_H
#ifndef QMLPROFILERDATAMODEL_H
#define QMLPROFILERDATAMODEL_H
#include "qmlprofiler_global.h"
#include "qmlprofilerbasemodel.h"
#include <qmldebug/qmlprofilereventlocation.h>
#include <QObject>
#include <QVector>
#include <QStringList>
namespace QmlProfiler {
class QmlProfilerModelManager;
// stores the data from the client as-is
class QMLPROFILER_EXPORT QmlProfilerSimpleModel : public QmlProfilerBaseModel
class QMLPROFILER_EXPORT QmlProfilerDataModel : public QmlProfilerBaseModel
{
Q_OBJECT
public:
@@ -63,22 +53,24 @@ public:
qint64 numericData5;
};
explicit QmlProfilerSimpleModel(QmlProfilerModelManager *parent);
~QmlProfilerSimpleModel();
explicit QmlProfilerDataModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent = 0);
virtual void clear();
bool isEmpty() const;
const QVector<QmlEventData> &getEvents() const;
int count() const;
void addQmlEvent(int type, int bindingType, qint64 startTime, qint64 duration, const QStringList &data, const QmlDebug::QmlEventLocation &location,
virtual void clear();
virtual bool isEmpty() const;
virtual void complete();
void addQmlEvent(int type, int bindingType, qint64 startTime, qint64 duration,
const QStringList &data, const QmlDebug::QmlEventLocation &location,
qint64 ndata1, qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5);
static QString getHashString(const QmlProfilerDataModel::QmlEventData &event);
qint64 lastTimeMark() const;
static QString getHashString(const QmlProfilerSimpleModel::QmlEventData &event);
static QString formatTime(qint64 timestamp);
protected slots:
void detailsChanged(int requestId, const QString &newString);
protected:
QVector<QmlEventData> eventList;
private:
QVector<QmlEventData> m_eventList;
};
}

View File

@@ -29,7 +29,7 @@
#include "qmlprofilereventsmodelproxy.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilersimplemodel.h"
#include "qmlprofilerdatamodel.h"
#include <utils/qtcassert.h>
@@ -66,7 +66,7 @@ QmlProfilerEventsModelProxy::QmlProfilerEventsModelProxy(QmlProfilerModelManager
: QObject(parent), d(new QmlProfilerEventsModelProxyPrivate(this))
{
d->modelManager = modelManager;
connect(modelManager->simpleModel(), SIGNAL(changed()), this, SLOT(dataChanged()));
connect(modelManager->qmlModel(), SIGNAL(changed()), this, SLOT(dataChanged()));
d->modelId = modelManager->registerModelProxy();
// We're iterating twice in loadData.
@@ -120,16 +120,16 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd)
const bool checkRanges = (rangeStart != -1) && (rangeEnd != -1);
const QVector<QmlProfilerSimpleModel::QmlEventData> eventList
= d->modelManager->simpleModel()->getEvents();
const QVector<QmlProfilerDataModel::QmlEventData> eventList
= d->modelManager->qmlModel()->getEvents();
// used by binding loop detection
typedef QPair<QString, const QmlProfilerSimpleModel::QmlEventData*> CallStackEntry;
typedef QPair<QString, const QmlProfilerDataModel::QmlEventData*> CallStackEntry;
QStack<CallStackEntry> callStack;
callStack.push(CallStackEntry(QString(), 0)); // artificial root
for (int i = 0; i < eventList.size(); ++i) {
const QmlProfilerSimpleModel::QmlEventData *event = &eventList[i];
const QmlProfilerDataModel::QmlEventData *event = &eventList[i];
if (!d->acceptedTypes.contains(event->eventType))
continue;
@@ -141,7 +141,7 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd)
}
// put event in hash
QString hash = QmlProfilerSimpleModel::getHashString(*event);
QString hash = QmlProfilerDataModel::getHashString(*event);
if (!d->data.contains(hash)) {
QmlEventStats stats = {
event->displayName,
@@ -190,7 +190,7 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd)
//
// binding loop detection
//
const QmlProfilerSimpleModel::QmlEventData *potentialParent = callStack.top().second;
const QmlProfilerDataModel::QmlEventData *potentialParent = callStack.top().second;
while (potentialParent
&& !(potentialParent->startTime + potentialParent->duration > event->startTime)) {
callStack.pop();
@@ -275,7 +275,7 @@ QmlProfilerEventRelativesModelProxy::QmlProfilerEventRelativesModelProxy(QmlProf
{
QTC_CHECK(modelManager);
m_modelManager = modelManager;
connect(modelManager->simpleModel(), SIGNAL(changed()), this, SLOT(dataChanged()));
connect(modelManager->qmlModel(), SIGNAL(changed()), this, SLOT(dataChanged()));
QTC_CHECK(eventsModel);
m_eventsModel = eventsModel;
@@ -325,13 +325,13 @@ QmlProfilerEventParentsModelProxy::~QmlProfilerEventParentsModelProxy()
void QmlProfilerEventParentsModelProxy::loadData()
{
clear();
QmlProfilerSimpleModel *simpleModel = m_modelManager->simpleModel();
QmlProfilerDataModel *simpleModel = m_modelManager->qmlModel();
if (simpleModel->isEmpty())
return;
QHash<QString, QmlProfilerSimpleModel::QmlEventData> cachedEvents;
QHash<QString, QmlProfilerDataModel::QmlEventData> cachedEvents;
QString rootEventName = tr("<program>");
QmlProfilerSimpleModel::QmlEventData rootEvent = {
QmlProfilerDataModel::QmlEventData rootEvent = {
rootEventName,
QmlDebug::Binding,
0,
@@ -353,8 +353,8 @@ void QmlProfilerEventParentsModelProxy::loadData()
// compute parent-child relationship and call count
QHash<int, QString> lastParent;
//for (int index = fromIndex; index <= toIndex; index++) {
const QVector<QmlProfilerSimpleModel::QmlEventData> eventList = simpleModel->getEvents();
foreach (const QmlProfilerSimpleModel::QmlEventData &event, eventList) {
const QVector<QmlProfilerDataModel::QmlEventData> eventList = simpleModel->getEvents();
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) {
// whitelist
if (!m_acceptedTypes.contains(event.eventType))
continue;
@@ -370,7 +370,7 @@ void QmlProfilerEventParentsModelProxy::loadData()
QString parentHash = rootEventName;
QString eventHash = QmlProfilerSimpleModel::getHashString(event);
QString eventHash = QmlProfilerDataModel::getHashString(event);
// save in cache
if (!cachedEvents.contains(eventHash))
@@ -379,7 +379,7 @@ void QmlProfilerEventParentsModelProxy::loadData()
if (level > QmlDebug::Constants::QML_MIN_LEVEL && lastParent.contains(level-1))
parentHash = lastParent[level-1];
QmlProfilerSimpleModel::QmlEventData *parentEvent = &(cachedEvents[parentHash]);
QmlProfilerDataModel::QmlEventData *parentEvent = &(cachedEvents[parentHash]);
// generate placeholder if needed
if (!m_data.contains(eventHash))
@@ -418,7 +418,7 @@ QmlProfilerEventChildrenModelProxy::~QmlProfilerEventChildrenModelProxy()
void QmlProfilerEventChildrenModelProxy::loadData()
{
clear();
QmlProfilerSimpleModel *simpleModel = m_modelManager->simpleModel();
QmlProfilerDataModel *simpleModel = m_modelManager->qmlModel();
if (simpleModel->isEmpty())
return;
@@ -433,8 +433,8 @@ void QmlProfilerEventChildrenModelProxy::loadData()
// compute parent-child relationship and call count
QHash<int, QString> lastParent;
const QVector<QmlProfilerSimpleModel::QmlEventData> eventList = simpleModel->getEvents();
foreach (const QmlProfilerSimpleModel::QmlEventData &event, eventList) {
const QVector<QmlProfilerDataModel::QmlEventData> eventList = simpleModel->getEvents();
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) {
// whitelist
if (!m_acceptedTypes.contains(event.eventType))
continue;
@@ -449,7 +449,7 @@ void QmlProfilerEventChildrenModelProxy::loadData()
endtimesPerLevel[level] = event.startTime + event.duration;
QString parentHash = rootEventName;
QString eventHash = QmlProfilerSimpleModel::getHashString(event);
QString eventHash = QmlProfilerDataModel::getHashString(event);
if (level > QmlDebug::Constants::QML_MIN_LEVEL && lastParent.contains(level-1))
parentHash = lastParent[level-1];

View File

@@ -31,7 +31,7 @@
#ifndef QMLPROFILEREVENTSMODELPROXY_H
#define QMLPROFILEREVENTSMODELPROXY_H
#include "qmlprofilersimplemodel.h"
#include "qmlprofilerdatamodel.h"
#include <QObject>
#include <qmldebug/qmlprofilereventtypes.h>
#include <qmldebug/qmlprofilereventlocation.h>

View File

@@ -544,7 +544,7 @@ void QmlProfilerEventsMainView::parseModelProxy()
}
if (d->m_fieldShown[TotalTime]) {
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.duration));
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.duration));
newRow.last()->setData(QVariant(event.duration));
}
@@ -554,22 +554,22 @@ void QmlProfilerEventsMainView::parseModelProxy()
}
if (d->m_fieldShown[TimePerCall]) {
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.timePerCall));
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.timePerCall));
newRow.last()->setData(QVariant(event.timePerCall));
}
if (d->m_fieldShown[MedianTime]) {
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.medianTime));
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.medianTime));
newRow.last()->setData(QVariant(event.medianTime));
}
if (d->m_fieldShown[MaxTime]) {
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.maxTime));
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.maxTime));
newRow.last()->setData(QVariant(event.maxTime));
}
if (d->m_fieldShown[MinTime]) {
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.minTime));
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.minTime));
newRow.last()->setData(QVariant(event.minTime));
}
@@ -818,13 +818,13 @@ void QmlProfilerEventRelativesView::rebuildTree(QmlProfilerEventRelativesModelPr
// no indirections at this level of abstraction!
newRow << new EventsViewItem(event.displayName);
newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event.eventType));
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event.duration));
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event.duration));
newRow << new EventsViewItem(QString::number(event.calls));
newRow << new EventsViewItem(event.details);
// newRow << new EventsViewItem(event->reference->displayName);
// newRow << new EventsViewItem(QmlProfilerEventsMainView::nameForType(event->reference->eventType));
// newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event->duration));
// newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event->duration));
// newRow << new EventsViewItem(QString::number(event->calls));
// newRow << new EventsViewItem(event->reference->details);
newRow.at(0)->setData(QVariant(key), EventHashStrRole);

View File

@@ -28,8 +28,7 @@
****************************************************************************/
#include "qmlprofilermodelmanager.h"
#include "qmlprofilersimplemodel.h"
#include "qmlprofilerprocessedmodel.h"
#include "qmlprofilerdatamodel.h"
#include "qv8profilerdatamodel.h"
#include "qmlprofilertracefile.h"
@@ -139,7 +138,7 @@ public:
~QmlProfilerModelManagerPrivate() {}
QmlProfilerModelManager *q;
QmlProfilerSimpleModel *model;
QmlProfilerDataModel *model;
QV8ProfilerDataModel *v8Model;
QmlProfilerDataState *dataState;
QmlProfilerTraceTime *traceTime;
@@ -160,7 +159,7 @@ QmlProfilerModelManager::QmlProfilerModelManager(Utils::FileInProjectFinder *fin
QObject(parent), d(new QmlProfilerModelManagerPrivate(this))
{
d->totalWeight = 0;
d->model = new QmlProfilerProcessedModel(finder, this);
d->model = new QmlProfilerDataModel(finder, this);
d->v8Model = new QV8ProfilerDataModel(finder, this);
// d->model = new QmlProfilerSimpleModel(this);
d->dataState = new QmlProfilerDataState(this, this);
@@ -177,7 +176,7 @@ QmlProfilerTraceTime *QmlProfilerModelManager::traceTime() const
return d->traceTime;
}
QmlProfilerSimpleModel *QmlProfilerModelManager::simpleModel() const
QmlProfilerDataModel *QmlProfilerModelManager::qmlModel() const
{
return d->model;
}

View File

@@ -38,12 +38,12 @@
#include <QObject>
namespace QmlProfiler {
class QmlProfilerSimpleModel;
class QmlProfilerModelManager;
class QmlProfilerDataModel;
class QV8ProfilerDataModel;
namespace Internal {
class QV8ProfilerDataModel;
class QmlProfilerDataState : public QObject
{
Q_OBJECT
@@ -109,7 +109,7 @@ public:
QmlProfilerDataState::State state() const;
QmlProfilerTraceTime *traceTime() const;
QmlProfilerSimpleModel *simpleModel() const;
QmlProfilerDataModel *qmlModel() const;
QV8ProfilerDataModel *v8Model() const;
bool isEmpty() const;

View File

@@ -29,7 +29,7 @@
#include "qmlprofilerpainteventsmodelproxy.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilersimplemodel.h"
#include "qmlprofilerdatamodel.h"
#include "sortedtimelinemodel.h"
#include "singlecategorytimelinemodel_p.h"
#include <QCoreApplication>
@@ -85,7 +85,7 @@ void PaintEventsModelProxy::clear()
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
}
bool PaintEventsModelProxy::eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const
bool PaintEventsModelProxy::eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const
{
return SingleCategoryTimelineModel::eventAccepted(event) &&
event.bindingType == QmlDebug::AnimationFrame;
@@ -95,17 +95,17 @@ void PaintEventsModelProxy::loadData()
{
Q_D(PaintEventsModelProxy);
clear();
QmlProfilerSimpleModel *simpleModel = d->modelManager->simpleModel();
QmlProfilerDataModel *simpleModel = d->modelManager->qmlModel();
if (simpleModel->isEmpty())
return;
// collect events
const QVector<QmlProfilerSimpleModel::QmlEventData> referenceList = simpleModel->getEvents();
const QVector<QmlProfilerDataModel::QmlEventData> referenceList = simpleModel->getEvents();
QmlPaintEventData lastEvent;
qint64 minNextStartTime = 0;
foreach (const QmlProfilerSimpleModel::QmlEventData &event, referenceList) {
foreach (const QmlProfilerDataModel::QmlEventData &event, referenceList) {
if (!eventAccepted(event)) {
if (event.eventType == QmlDebug::Painting)
d->seenForeignPaintEvent = true;
@@ -238,7 +238,7 @@ const QVariantList PaintEventsModelProxy::getEventDetails(int index) const
{
QVariantMap valuePair;
valuePair.insert(QCoreApplication::translate(trContext, "Duration:"),
QVariant(QmlProfilerSimpleModel::formatTime(d->range(index).duration)));
QVariant(QmlProfilerBaseModel::formatTime(d->range(index).duration)));
result << valuePair;
}

View File

@@ -39,7 +39,7 @@
//#include <QVector>
#include <QVariantList>
//#include <QVariantMap>
#include "qmlprofilersimplemodel.h"
#include "qmlprofilerdatamodel.h"
#include <QColor>
@@ -76,7 +76,7 @@ public:
Q_INVOKABLE const QVariantList getEventDetails(int index) const;
private slots:
bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const;
bool eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const;
private:
class PaintEventsModelProxyPrivate;

View File

@@ -1,62 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QMLPROFILERPROCESSEDMODEL_H
#define QMLPROFILERPROCESSEDMODEL_H
#include "qmlprofilersimplemodel.h"
#include "qmlprofilerdetailsrewriter.h"
namespace QmlProfiler {
namespace Internal {
class QmlProfilerProcessedModel : public QmlProfilerSimpleModel
{
Q_OBJECT
public:
explicit QmlProfilerProcessedModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent = 0);
~QmlProfilerProcessedModel();
virtual void clear();
virtual void complete();
private slots:
void detailsChanged(int requestId, const QString &newString);
void detailsDone();
private:
int m_processedModelId;
QmlProfilerDetailsRewriter *m_detailsRewriter;
};
}
}
#endif

View File

@@ -1,118 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qmlprofilersimplemodel.h"
#include "qmlprofilermodelmanager.h"
#include <qmldebug/qmlprofilereventtypes.h>
#include <QStringList>
#include <QVector>
#include <QDebug>
namespace QmlProfiler {
QmlProfilerSimpleModel::QmlProfilerSimpleModel(QmlProfilerModelManager *parent)
: QmlProfilerBaseModel(parent)
{
m_modelManager->setProxyCountWeight(m_modelId, 2);
}
QmlProfilerSimpleModel::~QmlProfilerSimpleModel()
{
}
void QmlProfilerSimpleModel::clear()
{
eventList.clear();
QmlProfilerBaseModel::clear();
}
bool QmlProfilerSimpleModel::isEmpty() const
{
return eventList.isEmpty();
}
const QVector<QmlProfilerSimpleModel::QmlEventData> &QmlProfilerSimpleModel::getEvents() const
{
return eventList;
}
int QmlProfilerSimpleModel::count() const
{
return eventList.count();
}
void QmlProfilerSimpleModel::addQmlEvent(int type, int bindingType, qint64 startTime, qint64 duration, const QStringList &data, const QmlDebug::QmlEventLocation &location, qint64 ndata1, qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5)
{
QString displayName;
if (type == QmlDebug::Painting && bindingType == QmlDebug::AnimationFrame) {
displayName = tr("Animations");
} else {
displayName = QString::fromLatin1("%1:%2").arg(
location.filename,
QString::number(location.line));
}
QmlEventData eventData = {displayName, type, bindingType, startTime, duration, data, location, ndata1, ndata2, ndata3, ndata4, ndata5};
eventList.append(eventData);
m_modelManager->modelProxyCountUpdated(m_modelId, startTime, m_modelManager->estimatedProfilingTime());
}
qint64 QmlProfilerSimpleModel::lastTimeMark() const
{
if (eventList.isEmpty())
return 0;
return eventList.last().startTime + eventList.last().duration;
}
QString QmlProfilerSimpleModel::getHashString(const QmlProfilerSimpleModel::QmlEventData &event)
{
return QString::fromLatin1("%1:%2:%3:%4:%5").arg(
event.location.filename,
QString::number(event.location.line),
QString::number(event.location.column),
QString::number(event.eventType),
QString::number(event.bindingType));
}
QString QmlProfilerSimpleModel::formatTime(qint64 timestamp)
{
if (timestamp < 1e6)
return QString::number(timestamp/1e3f,'f',3) + trUtf8(" \xc2\xb5s");
if (timestamp < 1e9)
return QString::number(timestamp/1e6f,'f',3) + tr(" ms");
return QString::number(timestamp/1e9f,'f',3) + tr(" s");
}
}

View File

@@ -29,7 +29,7 @@
#include "qmlprofilertimelinemodelproxy.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilersimplemodel.h"
#include "qmlprofilerdatamodel.h"
#include "sortedtimelinemodel.h"
#include <QCoreApplication>
@@ -96,7 +96,7 @@ void BasicTimelineModel::BasicTimelineModelPrivate::prepare()
}
}
bool BasicTimelineModel::eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const
bool BasicTimelineModel::eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const
{
// only accept Qt4.x Painting events
if (event.eventType == QmlDebug::Painting)
@@ -109,7 +109,7 @@ void BasicTimelineModel::loadData()
{
Q_D(BasicTimelineModel);
clear();
QmlProfilerSimpleModel *simpleModel = d->modelManager->simpleModel();
QmlProfilerDataModel *simpleModel = d->modelManager->qmlModel();
if (simpleModel->isEmpty())
return;
@@ -118,14 +118,14 @@ void BasicTimelineModel::loadData()
d->prepare();
// collect events
const QVector<QmlProfilerSimpleModel::QmlEventData> eventList = simpleModel->getEvents();
foreach (const QmlProfilerSimpleModel::QmlEventData &event, eventList) {
const QVector<QmlProfilerDataModel::QmlEventData> eventList = simpleModel->getEvents();
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) {
if (!eventAccepted(event))
continue;
if (event.eventType == QmlDebug::Painting)
d->seenPaintEvent = true;
QString eventHash = QmlProfilerSimpleModel::getHashString(event);
QString eventHash = QmlProfilerDataModel::getHashString(event);
// store in dictionary
if (!d->eventHashes.contains(eventHash)) {
@@ -413,7 +413,7 @@ const QVariantList BasicTimelineModel::getEventDetails(int index) const
{
QVariantMap valuePair;
valuePair.insert(QCoreApplication::translate(trContext, "Duration:"),
QVariant(QmlProfilerSimpleModel::formatTime(d->range(index).duration)));
QVariant(QmlProfilerBaseModel::formatTime(d->range(index).duration)));
result << valuePair;
}

View File

@@ -39,7 +39,7 @@
//#include <QVector>
#include <QVariantList>
//#include <QVariantMap>
#include "qmlprofilersimplemodel.h"
#include "qmlprofilerdatamodel.h"
#include <QColor>
@@ -108,7 +108,7 @@ public:
Q_INVOKABLE int getEventIdForLocation(const QString &filename, int line, int column) const;
private slots:
bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const;
bool eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const;
private:
class BasicTimelineModelPrivate;

View File

@@ -401,10 +401,10 @@ void QmlProfilerFileWriter::setV8DataModel(QV8ProfilerDataModel *dataModel)
m_v8Model = dataModel;
}
void QmlProfilerFileWriter::setQmlEvents(const QVector<QmlProfilerSimpleModel::QmlEventData> &events)
void QmlProfilerFileWriter::setQmlEvents(const QVector<QmlProfilerDataModel::QmlEventData> &events)
{
foreach (const QmlProfilerSimpleModel::QmlEventData &event, events) {
const QString hashStr = QmlProfilerSimpleModel::getHashString(event);
foreach (const QmlProfilerDataModel::QmlEventData &event, events) {
const QString hashStr = QmlProfilerDataModel::getHashString(event);
if (!m_qmlEvents.contains(hashStr)) {
QmlEvent e = { event.displayName,
event.location.filename,
@@ -524,7 +524,7 @@ void QmlProfilerFileWriter::save(QIODevice *device)
stream.writeEndDocument();
}
void QmlProfilerFileWriter::calculateMeasuredTime(const QVector<QmlProfilerSimpleModel::QmlEventData> &events)
void QmlProfilerFileWriter::calculateMeasuredTime(const QVector<QmlProfilerDataModel::QmlEventData> &events)
{
// measured time isn't used, but old clients might still need it
// -> we calculate it explicitly
@@ -535,7 +535,7 @@ void QmlProfilerFileWriter::calculateMeasuredTime(const QVector<QmlProfilerSimpl
int level = QmlDebug::Constants::QML_MIN_LEVEL;
endtimesPerLevel[0] = 0;
foreach (const QmlProfilerSimpleModel::QmlEventData &event, events) {
foreach (const QmlProfilerDataModel::QmlEventData &event, events) {
// whitelist
if (!m_acceptedTypes.contains(event.eventType))
continue;

View File

@@ -37,7 +37,7 @@
#include <qmldebug/qmlprofilereventlocation.h>
#include <qmldebug/qmlprofilereventtypes.h>
#include "qmlprofilersimplemodel.h"
#include "qmlprofilerdatamodel.h"
#include "qv8profilerdatamodel.h"
QT_FORWARD_DECLARE_CLASS(QIODevice)
@@ -112,12 +112,12 @@ public:
void setTraceTime(qint64 startTime, qint64 endTime, qint64 measturedTime);
void setV8DataModel(QV8ProfilerDataModel *dataModel);
void setQmlEvents(const QVector<QmlProfilerSimpleModel::QmlEventData> &events);
void setQmlEvents(const QVector<QmlProfilerDataModel::QmlEventData> &events);
void save(QIODevice *device);
private:
void calculateMeasuredTime(const QVector<QmlProfilerSimpleModel::QmlEventData> &events);
void calculateMeasuredTime(const QVector<QmlProfilerDataModel::QmlEventData> &events);
qint64 m_startTime, m_endTime, m_measuredTime;

View File

@@ -35,12 +35,11 @@
#include <QStringList>
QT_BEGIN_NAMESPACE
Q_DECLARE_TYPEINFO(QmlProfiler::Internal::QV8EventData, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QmlProfiler::Internal::QV8EventSub, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QmlProfiler::QV8EventData, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QmlProfiler::QV8EventSub, Q_MOVABLE_TYPE);
QT_END_NAMESPACE
namespace QmlProfiler {
namespace Internal {
typedef QHash <QString, QV8EventSub *> EventHash;
@@ -101,35 +100,23 @@ class QV8ProfilerDataModel::QV8ProfilerDataModelPrivate
public:
QV8ProfilerDataModelPrivate(QV8ProfilerDataModel *qq) {Q_UNUSED(qq);}
void clearV8RootEvent();
void collectV8Statistics();
QHash<QString, QV8EventData *> v8EventHash;
QList<QV8EventData *> pendingRewrites;
QHash<int, QV8EventData *> v8parents;
QV8EventData v8RootEvent;
qint64 v8MeasuredTime;
QmlProfilerDetailsRewriter *detailsRewriter;
};
QV8ProfilerDataModel::QV8ProfilerDataModel(Utils::FileInProjectFinder *fileFinder,
QmlProfilerModelManager *parent)
: QmlProfilerBaseModel(parent)
, d(new QV8ProfilerDataModelPrivate(this))
: QmlProfilerBaseModel(fileFinder, parent), d(new QV8ProfilerDataModelPrivate(this))
{
d->detailsRewriter = new QmlProfilerDetailsRewriter(this, fileFinder);
d->v8MeasuredTime = 0;
d->clearV8RootEvent();
connect(d->detailsRewriter, SIGNAL(rewriteDetailsString(int,QString)),
this, SLOT(detailsChanged(int,QString)));
connect(d->detailsRewriter, SIGNAL(eventDetailsChanged()),
this, SLOT(detailsDone()));
clearV8RootEvent();
}
QV8ProfilerDataModel::~QV8ProfilerDataModel()
{
delete d->detailsRewriter;
delete d;
}
@@ -138,9 +125,8 @@ void QV8ProfilerDataModel::clear()
qDeleteAll(d->v8EventHash.values());
d->v8EventHash.clear();
d->v8parents.clear();
d->clearV8RootEvent();
clearV8RootEvent();
d->v8MeasuredTime = 0;
d->detailsRewriter->clearRequests();
d->pendingRewrites.clear();
QmlProfilerBaseModel::clear();
@@ -243,28 +229,21 @@ void QV8ProfilerDataModel::addV8Event(int depth,
void QV8ProfilerDataModel::detailsChanged(int requestId, const QString &newString)
{
QTC_ASSERT(requestId < d->pendingRewrites.count(), return);
QV8EventData *event = d->pendingRewrites[requestId];
event->filename = newString;
d->pendingRewrites[requestId]->filename = newString;
}
void QV8ProfilerDataModel::detailsDone()
{
d->pendingRewrites.clear();
QmlProfilerBaseModel::complete();
QmlProfilerBaseModel::detailsDone();
}
void QV8ProfilerDataModel::collectV8Statistics()
void QV8ProfilerDataModel::complete()
{
d->collectV8Statistics();
}
void QV8ProfilerDataModel::QV8ProfilerDataModelPrivate::collectV8Statistics()
{
if (!v8EventHash.isEmpty()) {
double totalTimes = v8MeasuredTime;
if (!d->v8EventHash.isEmpty()) {
double totalTimes = d->v8MeasuredTime;
double selfTimes = 0;
foreach (const QV8EventData *v8event, v8EventHash) {
foreach (const QV8EventData *v8event, d->v8EventHash) {
selfTimes += v8event->selfTime;
}
@@ -276,58 +255,59 @@ void QV8ProfilerDataModel::QV8ProfilerDataModelPrivate::collectV8Statistics()
// insert root event in eventlist
// the +1 ns is to get it on top of the sorted list
v8RootEvent.totalTime = v8MeasuredTime + 1;
v8RootEvent.selfTime = 0;
d->v8RootEvent.totalTime = d->v8MeasuredTime + 1;
d->v8RootEvent.selfTime = 0;
QString rootEventHash = getHashStringForV8Event(
tr("<program>"),
tr("Main Program"));
QV8EventData *v8RootEventPointer = v8EventHash[rootEventHash];
QV8EventData *v8RootEventPointer = d->v8EventHash[rootEventHash];
if (v8RootEventPointer) {
v8RootEvent = *v8RootEventPointer;
d->v8RootEvent = *v8RootEventPointer;
} else {
v8EventHash[rootEventHash] = new QV8EventData;
*v8EventHash[rootEventHash] = v8RootEvent;
d->v8EventHash[rootEventHash] = new QV8EventData;
*(d->v8EventHash[rootEventHash]) = d->v8RootEvent;
}
foreach (QV8EventData *v8event, v8EventHash) {
foreach (QV8EventData *v8event, d->v8EventHash) {
v8event->totalPercent = v8event->totalTime * 100.0 / totalTimes;
v8event->SelfTimeInPercent = v8event->selfTime * 100.0 / selfTimes;
}
int index = pendingRewrites.size();
foreach (QV8EventData *v8event, v8EventHash.values()) {
int index = d->pendingRewrites.size();
foreach (QV8EventData *v8event, d->v8EventHash.values()) {
v8event->eventId = index++;
pendingRewrites << v8event;
detailsRewriter->requestDetailsForLocation(index,
d->pendingRewrites << v8event;
m_detailsRewriter.requestDetailsForLocation(index,
QmlDebug::QmlEventLocation(v8event->filename, v8event->line, 1));
}
v8RootEvent.eventId = v8EventHash[rootEventHash]->eventId;
d->v8RootEvent.eventId = d->v8EventHash[rootEventHash]->eventId;
} else {
// On empty data, still add a fake root event
clearV8RootEvent();
}
detailsRewriter->reloadDocuments();
QmlProfilerBaseModel::complete();
}
void QV8ProfilerDataModel::QV8ProfilerDataModelPrivate::clearV8RootEvent()
void QV8ProfilerDataModel::clearV8RootEvent()
{
v8RootEvent.displayName = tr("<program>");
v8RootEvent.eventHashStr = tr("<program>");
v8RootEvent.functionName = tr("Main Program");
d->v8RootEvent.displayName = tr("<program>");
d->v8RootEvent.eventHashStr = tr("<program>");
d->v8RootEvent.functionName = tr("Main Program");
v8RootEvent.line = -1;
v8RootEvent.totalTime = 0;
v8RootEvent.totalPercent = 0;
v8RootEvent.selfTime = 0;
v8RootEvent.SelfTimeInPercent = 0;
v8RootEvent.eventId = -1;
d->v8RootEvent.line = -1;
d->v8RootEvent.totalTime = 0;
d->v8RootEvent.totalPercent = 0;
d->v8RootEvent.selfTime = 0;
d->v8RootEvent.SelfTimeInPercent = 0;
d->v8RootEvent.eventId = -1;
qDeleteAll(v8RootEvent.parentHash.values());
qDeleteAll(v8RootEvent.childrenHash.values());
v8RootEvent.parentHash.clear();
v8RootEvent.childrenHash.clear();
qDeleteAll(d->v8RootEvent.parentHash.values());
qDeleteAll(d->v8RootEvent.childrenHash.values());
d->v8RootEvent.parentHash.clear();
d->v8RootEvent.childrenHash.clear();
}
void QV8ProfilerDataModel::save(QXmlStreamWriter &stream)
@@ -509,14 +489,7 @@ void QV8ProfilerDataModel::load(QXmlStreamReader &stream)
d->v8EventHash[storedV8Event->eventHashStr] = storedV8Event;
}
d->collectV8Statistics();
complete();
}
void QV8ProfilerDataModel::complete()
{
collectV8Statistics();
}
} // namespace Internal
} // namespace QmlProfiler

View File

@@ -40,7 +40,6 @@
#include <QXmlStreamWriter>
namespace QmlProfiler {
namespace Internal {
struct QV8EventSub;
@@ -86,7 +85,6 @@ public:
QV8EventData *v8EventDescription(int eventId) const;
qint64 v8MeasuredTime() const;
void collectV8Statistics();
void save(QXmlStreamWriter &stream);
void load(QXmlStreamReader &stream);
@@ -106,9 +104,9 @@ public slots:
private:
class QV8ProfilerDataModelPrivate;
QV8ProfilerDataModelPrivate *d;
void clearV8RootEvent();
};
} // namespace Internal
} // namespace QmlProfiler
#endif // QV8PROFILERDATAMODEL_H

View File

@@ -443,7 +443,7 @@ void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFr
}
if (m_fieldShown[TotalTime]) {
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(v8event->totalTime));
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(v8event->totalTime));
newRow.last()->setData(QVariant(v8event->totalTime));
}
@@ -453,7 +453,7 @@ void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFr
}
if (m_fieldShown[SelfTime]) {
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(v8event->selfTime));
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(v8event->selfTime));
newRow.last()->setData(QVariant(v8event->selfTime));
}
@@ -665,7 +665,7 @@ void QV8ProfilerEventRelativesView::rebuildTree(QList<QV8EventSub*> events)
foreach (QV8EventSub *event, events) {
QList<QStandardItem *> newRow;
newRow << new EventsViewItem(event->reference->displayName);
newRow << new EventsViewItem(QmlProfilerSimpleModel::formatTime(event->totalTime));
newRow << new EventsViewItem(QmlProfilerBaseModel::formatTime(event->totalTime));
newRow << new EventsViewItem(event->reference->functionName);
newRow.at(0)->setData(QVariant(event->reference->eventId), EventIdRole);
newRow.at(1)->setData(QVariant(event->totalTime));

View File

@@ -41,11 +41,12 @@
#include "qmlprofilerviewmanager.h"
namespace QmlProfiler {
struct QV8EventSub;
namespace Internal {
class QV8ProfilerEventsMainView;
class QV8ProfilerEventRelativesView;
struct QV8EventSub;
class QV8ProfilerEventsWidget : public QWidget

View File

@@ -45,7 +45,7 @@ SingleCategoryTimelineModel::SingleCategoryTimelineModel(SingleCategoryTimelineM
/////////////////// QML interface
bool SingleCategoryTimelineModel::eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const
bool SingleCategoryTimelineModel::eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const
{
Q_D(const SingleCategoryTimelineModel);
return (event.eventType == d->eventType);

View File

@@ -39,7 +39,7 @@ class QMLPROFILER_EXPORT SingleCategoryTimelineModel : public AbstractTimelineMo
{
Q_OBJECT
public:
bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const;
bool eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const;
Q_INVOKABLE bool expanded(int) const;
Q_INVOKABLE void setExpanded(int, bool expanded);

View File

@@ -143,7 +143,7 @@ bool TimelineModelAggregator::isEmpty() const
return true;
}
bool TimelineModelAggregator::eventAccepted(const QmlProfilerSimpleModel::QmlEventData &/*event*/) const
bool TimelineModelAggregator::eventAccepted(const QmlProfilerDataModel::QmlEventData &/*event*/) const
{
// accept all events
return true;

View File

@@ -61,7 +61,7 @@ public:
bool isEmpty() const;
bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const;
bool eventAccepted(const QmlProfilerDataModel::QmlEventData &event) const;
Q_INVOKABLE int basicModelIndex() const;