diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-03-17 14:52:01 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-18 12:02:48 +0100 |
commit | d7ea461fde7a5d227313eda83b5af84ec9b0477b (patch) | |
tree | 4123a75392fa5ffb4fc0574c1e794bae311ad261 /tools | |
parent | 5977fbfd16f4d2d268dfecc48b1120a1f0dcf004 (diff) |
Save painting events in Qt5 style with thread ID from qmlprofiler
This is necessary to support https://codereview.qt-project.org/80391
and to make the trace files consistent with Qt Creator's.
Change-Id: I45490c33ae9bd8fbbb6bace08bdc2f44c76bf966
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmlprofiler/qmlprofilerapplication.cpp | 2 | ||||
-rw-r--r-- | tools/qmlprofiler/qmlprofilerclient.cpp | 5 | ||||
-rw-r--r-- | tools/qmlprofiler/qmlprofilerclient.h | 2 | ||||
-rw-r--r-- | tools/qmlprofiler/qmlprofilerdata.cpp | 35 | ||||
-rw-r--r-- | tools/qmlprofiler/qmlprofilerdata.h | 2 |
5 files changed, 24 insertions, 22 deletions
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp index 6c3e697f56..4c05fe8d64 100644 --- a/tools/qmlprofiler/qmlprofilerapplication.cpp +++ b/tools/qmlprofiler/qmlprofilerapplication.cpp @@ -108,7 +108,7 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) : &m_profilerData, SLOT(addQmlEvent(QQmlProfilerService::RangeType,QQmlProfilerService::BindingType,qint64,qint64,QStringList,QmlEventLocation))); connect(&m_qmlProfilerClient, SIGNAL(traceFinished(qint64)), &m_profilerData, SLOT(setTraceEndTime(qint64))); connect(&m_qmlProfilerClient, SIGNAL(traceStarted(qint64)), &m_profilerData, SLOT(setTraceStartTime(qint64))); - connect(&m_qmlProfilerClient, SIGNAL(frame(qint64,int,int)), &m_profilerData, SLOT(addFrameEvent(qint64,int,int))); + connect(&m_qmlProfilerClient, SIGNAL(frame(qint64,int,int,int)), &m_profilerData, SLOT(addFrameEvent(qint64,int,int,int))); connect(&m_qmlProfilerClient, SIGNAL(complete()), this, SLOT(qmlComplete())); connect(&m_v8profilerClient, SIGNAL(enabledChanged()), this, SLOT(profilerClientEnabled())); diff --git a/tools/qmlprofiler/qmlprofilerclient.cpp b/tools/qmlprofiler/qmlprofilerclient.cpp index 25557af77f..23a75d0576 100644 --- a/tools/qmlprofiler/qmlprofilerclient.cpp +++ b/tools/qmlprofiler/qmlprofilerclient.cpp @@ -174,8 +174,11 @@ void QmlProfilerClient::messageReceived(const QByteArray &data) d->maximumTime = qMax(time, d->maximumTime); } else if (event == QQmlProfilerService::AnimationFrame) { int frameRate, animationCount; + int threadId = 0; stream >> frameRate >> animationCount; - emit this->frame(time, frameRate, animationCount); + if (!stream.atEnd()) + stream >> threadId; + emit this->frame(time, frameRate, animationCount, threadId); d->maximumTime = qMax(time, d->maximumTime); } else if (event == QQmlProfilerService::StartTrace) { emit this->traceStarted(time); diff --git a/tools/qmlprofiler/qmlprofilerclient.h b/tools/qmlprofiler/qmlprofilerclient.h index e0bba0b660..29492c49ff 100644 --- a/tools/qmlprofiler/qmlprofilerclient.h +++ b/tools/qmlprofiler/qmlprofilerclient.h @@ -102,7 +102,7 @@ signals: qint64 startTime, qint64 length, const QStringList &data, const QmlEventLocation &location); - void frame(qint64 time, int frameRate, int animationCount); + void frame(qint64 time, int frameRate, int animationCount, int threadId); protected: virtual void messageReceived(const QByteArray &); diff --git a/tools/qmlprofiler/qmlprofilerdata.cpp b/tools/qmlprofiler/qmlprofilerdata.cpp index 038d2177f9..00dc09901f 100644 --- a/tools/qmlprofiler/qmlprofilerdata.cpp +++ b/tools/qmlprofiler/qmlprofilerdata.cpp @@ -56,6 +56,9 @@ namespace Constants { const char TYPE_BINDING_STR[] = "Binding"; const char TYPE_HANDLINGSIGNAL_STR[] = "HandlingSignal"; const char PROFILER_FILE_VERSION[] = "1.02"; + + // Save animation frames in "Qt5 style", 3 would mean Qt4 + const int ANIMATION_FRAME_TYPE = 4; } struct QmlRangeEventData { @@ -79,14 +82,15 @@ struct QmlRangeEventData { struct QmlRangeEventStartInstance { QmlRangeEventStartInstance() {} // never called QmlRangeEventStartInstance(qint64 _startTime, qint64 _duration, int _frameRate, - int _animationCount, QmlRangeEventData *_data) + int _animationCount, int _threadId, QmlRangeEventData *_data) : startTime(_startTime), duration(_duration), frameRate(_frameRate), - animationCount(_animationCount), data(_data) + animationCount(_animationCount), threadId(_threadId), data(_data) { } qint64 startTime; qint64 duration; int frameRate; int animationCount; + int threadId; QmlRangeEventData *data; }; @@ -122,7 +126,6 @@ public: qint64 traceEndTime; // internal state while collecting events - QmlRangeEventStartInstance *lastFrameEvent; qint64 qmlMeasuredTime; qint64 v8MeasuredTime; QHash<int, QV8EventInfo *> v8parents; @@ -162,8 +165,6 @@ void QmlProfilerData::clear() d->traceStartTime = -1; d->qmlMeasuredTime = 0; - d->lastFrameEvent = 0; - setState(Empty); } @@ -271,12 +272,12 @@ void QmlProfilerData::addQmlEvent(QQmlProfilerService::RangeType type, d->eventDescriptions.insert(eventHashStr, newEvent); } - QmlRangeEventStartInstance rangeEventStartInstance(startTime, duration, 1e9/duration, -1, newEvent); + QmlRangeEventStartInstance rangeEventStartInstance(startTime, duration, -1, -1, -1, newEvent); d->startInstanceList.append(rangeEventStartInstance); } -void QmlProfilerData::addFrameEvent(qint64 time, int framerate, int animationcount) +void QmlProfilerData::addFrameEvent(qint64 time, int framerate, int animationcount, int threadId) { setState(AcquiringData); @@ -292,18 +293,10 @@ void QmlProfilerData::addFrameEvent(qint64 time, int framerate, int animationcou d->eventDescriptions.insert(eventHashStr, newEvent); } - qint64 duration = 1e9/framerate; - // avoid overlap - if (d->lastFrameEvent && - d->lastFrameEvent->startTime + d->lastFrameEvent->duration >= time) { - d->lastFrameEvent->duration = time - 1 - d->lastFrameEvent->startTime; - } - - QmlRangeEventStartInstance rangeEventStartInstance(time, duration, framerate, animationcount, newEvent); + QmlRangeEventStartInstance rangeEventStartInstance(time, -1, framerate, animationcount, + threadId, newEvent); d->startInstanceList.append(rangeEventStartInstance); - - d->lastFrameEvent = &d->startInstanceList.last(); } QString QmlProfilerData::rootEventName() @@ -502,6 +495,9 @@ bool QmlProfilerData::save(const QString &filename) stream.writeTextElement(QStringLiteral("details"), eventData->details); if (eventData->eventType == QQmlProfilerService::Binding) stream.writeTextElement(QStringLiteral("bindingType"), QString::number((int)eventData->bindingType)); + else if (eventData->eventType == QQmlProfilerService::Painting) + stream.writeTextElement(QStringLiteral("animationFrame"), + QString::number(Constants::ANIMATION_FRAME_TYPE)); stream.writeEndElement(); } stream.writeEndElement(); // eventData @@ -510,12 +506,15 @@ bool QmlProfilerData::save(const QString &filename) foreach (const QmlRangeEventStartInstance &rangedEvent, d->startInstanceList) { stream.writeStartElement(QStringLiteral("range")); stream.writeAttribute(QStringLiteral("startTime"), QString::number(rangedEvent.startTime)); - stream.writeAttribute(QStringLiteral("duration"), QString::number(rangedEvent.duration)); + if (rangedEvent.duration >= 0) + stream.writeAttribute(QStringLiteral("duration"), + QString::number(rangedEvent.duration)); stream.writeAttribute(QStringLiteral("eventIndex"), QString::number(d->eventDescriptions.keys().indexOf(rangedEvent.data->eventHashStr))); if (rangedEvent.data->eventType == QQmlProfilerService::Painting && rangedEvent.animationCount >= 0) { // animation frame stream.writeAttribute(QStringLiteral("framerate"), QString::number(rangedEvent.frameRate)); stream.writeAttribute(QStringLiteral("animationcount"), QString::number(rangedEvent.animationCount)); + stream.writeAttribute(QStringLiteral("thread"), QString::number(rangedEvent.threadId)); } stream.writeEndElement(); } diff --git a/tools/qmlprofiler/qmlprofilerdata.h b/tools/qmlprofiler/qmlprofilerdata.h index 134e7228af..a5d55ed6f6 100644 --- a/tools/qmlprofiler/qmlprofilerdata.h +++ b/tools/qmlprofiler/qmlprofilerdata.h @@ -88,7 +88,7 @@ public slots: const QmlEventLocation &location); void addV8Event(int depth, const QString &function, const QString &filename, int lineNumber, double totalTime, double selfTime); - void addFrameEvent(qint64 time, int framerate, int animationcount); + void addFrameEvent(qint64 time, int framerate, int animationcount, int threadId); void complete(); bool save(const QString &filename); |