aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-06-16 13:33:33 +0200
committerUlf Hermann <ulf.hermann@digia.com>2014-08-12 10:16:40 +0200
commit74f483f23140aaf77ab062bd53478cbb949fd2e2 (patch)
tree4f4ac704c96ec506de8c33829c534bede2a5ddbc /tools
parent99d0921e2d2a20b956cab172d472f7c369c05008 (diff)
Write memory events into tracefiles generated by qmlprofiler
Change-Id: Ic01505194f29967ed1aad16fe36e14dc5532ae25 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp4
-rw-r--r--tools/qmlprofiler/qmlprofilerclient.cpp6
-rw-r--r--tools/qmlprofiler/qmlprofilerclient.h1
-rw-r--r--tools/qmlprofiler/qmlprofilerdata.cpp23
-rw-r--r--tools/qmlprofiler/qmlprofilerdata.h1
5 files changed, 35 insertions, 0 deletions
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index e235f6cd03..9828074303 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -117,6 +117,10 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) :
QmlEventLocation,int,int,int)),
&m_profilerData, SLOT(addPixmapCacheEvent(QQmlProfilerService::PixmapEventType,qint64,
QmlEventLocation,int,int,int)));
+ connect(&m_qmlProfilerClient, SIGNAL(memoryAllocation(QQmlProfilerService::MemoryType,qint64,
+ qint64)),
+ &m_profilerData, SLOT(addMemoryEvent(QQmlProfilerService::MemoryType,qint64,
+ qint64)));
connect(&m_qmlProfilerClient, SIGNAL(complete()), this, SLOT(qmlComplete()));
diff --git a/tools/qmlprofiler/qmlprofilerclient.cpp b/tools/qmlprofiler/qmlprofilerclient.cpp
index 9322158280..14fc817807 100644
--- a/tools/qmlprofiler/qmlprofilerclient.cpp
+++ b/tools/qmlprofiler/qmlprofilerclient.cpp
@@ -216,6 +216,12 @@ void QmlProfilerClient::messageReceived(const QByteArray &data)
emit pixmapCache((QQmlProfilerService::PixmapEventType)pixEvTy, time,
QmlEventLocation(pixUrl,0,0), width, height, refcount);
d->maximumTime = qMax(time, d->maximumTime);
+ } else if (messageType == QQmlProfilerService::MemoryAllocation) {
+ int type;
+ qint64 delta;
+ stream >> type >> delta;
+ emit memoryAllocation((QQmlProfilerService::MemoryType)type, time, delta);
+ d->maximumTime = qMax(time, d->maximumTime);
} else {
int range;
stream >> range;
diff --git a/tools/qmlprofiler/qmlprofilerclient.h b/tools/qmlprofiler/qmlprofilerclient.h
index 67e5046f12..cdf80ff05a 100644
--- a/tools/qmlprofiler/qmlprofilerclient.h
+++ b/tools/qmlprofiler/qmlprofilerclient.h
@@ -108,6 +108,7 @@ signals:
qint64 numericData4, qint64 numericData5);
void pixmapCache(QQmlProfilerService::PixmapEventType, qint64 time,
const QmlEventLocation &location, int width, int height, int refCount);
+ void memoryAllocation(QQmlProfilerService::MemoryType type, qint64 time, qint64 amount);
protected:
virtual void messageReceived(const QByteArray &);
diff --git a/tools/qmlprofiler/qmlprofilerdata.cpp b/tools/qmlprofiler/qmlprofilerdata.cpp
index bf2d05ed7b..85efab94cd 100644
--- a/tools/qmlprofiler/qmlprofilerdata.cpp
+++ b/tools/qmlprofiler/qmlprofilerdata.cpp
@@ -378,6 +378,24 @@ void QmlProfilerData::addPixmapCacheEvent(QQmlProfilerDefinitions::PixmapEventTy
d->startInstanceList.append(rangeEventStartInstance);
}
+void QmlProfilerData::addMemoryEvent(QQmlProfilerService::MemoryType type, qint64 time,
+ qint64 size)
+{
+ setState(AcquiringData);
+ QString eventHashStr = QString::fromLatin1("MemoryAllocation:%1").arg(type);
+ QmlRangeEventData *newEvent;
+ if (d->eventDescriptions.contains(eventHashStr)) {
+ newEvent = d->eventDescriptions[eventHashStr];
+ } else {
+ newEvent = new QmlRangeEventData(eventHashStr, type, eventHashStr, QmlEventLocation(),
+ QString(), QQmlProfilerService::MemoryAllocation,
+ QQmlProfilerService::MaximumRangeType);
+ d->eventDescriptions.insert(eventHashStr, newEvent);
+ }
+ QmlRangeEventStartInstance rangeEventStartInstance(time, size, 0, 0, 0, 0, newEvent);
+ d->startInstanceList.append(rangeEventStartInstance);
+}
+
QString QmlProfilerData::rootEventName()
{
return tr("<program>");
@@ -589,6 +607,9 @@ bool QmlProfilerData::save(const QString &filename)
else if (eventData->message == QQmlProfilerService::SceneGraphFrame)
stream.writeTextElement(QStringLiteral("sgEventType"),
QString::number((int)eventData->detailType));
+ else if (eventData->message == QQmlProfilerService::MemoryAllocation)
+ stream.writeTextElement(QStringLiteral("memoryEventType"),
+ QString::number((int)eventData->detailType));
stream.writeEndElement();
}
stream.writeEndElement(); // eventData
@@ -636,6 +657,8 @@ bool QmlProfilerData::save(const QString &filename)
if (event.numericData5 > 0)
stream.writeAttribute(QStringLiteral("timing5"),
QString::number(event.numericData5));
+ } else if (event.data->message == QQmlProfilerService::MemoryAllocation) {
+ stream.writeAttribute(QStringLiteral("amount"), QString::number(event.numericData1));
}
stream.writeEndElement();
}
diff --git a/tools/qmlprofiler/qmlprofilerdata.h b/tools/qmlprofiler/qmlprofilerdata.h
index 47da0effbf..675c241abc 100644
--- a/tools/qmlprofiler/qmlprofilerdata.h
+++ b/tools/qmlprofiler/qmlprofilerdata.h
@@ -95,6 +95,7 @@ public slots:
qint64 numericData4, qint64 numericData5);
void addPixmapCacheEvent(QQmlProfilerService::PixmapEventType type, qint64 time,
const QmlEventLocation &location, int width, int height, int refcount);
+ void addMemoryEvent(QQmlProfilerService::MemoryType type, qint64 time, qint64 size);
void complete();
bool save(const QString &filename);