diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-09-17 13:34:38 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-10-30 20:07:45 +0000 |
commit | cdb0ddeffd1bab0afd4c763e44431b11c8e8e0b0 (patch) | |
tree | a131686359acd1f9bdc378fa5523a8d726397e6d /tools/qmlprofiler/qmlprofilerdata.cpp | |
parent | b5cd093559d71fb28c9c8e9cffc415e1aa1e7b11 (diff) |
QmlProfiler: Collect useful input events
Just "Key" or "Mouse" as only attributes of input events are not very
useful. This change adds some additional information and also collects
input events from QQuickWindow.
Change-Id: I062bbffeef3fa87776bc8be33f2321edf793faa2
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tools/qmlprofiler/qmlprofilerdata.cpp')
-rw-r--r-- | tools/qmlprofiler/qmlprofilerdata.cpp | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/tools/qmlprofiler/qmlprofilerdata.cpp b/tools/qmlprofiler/qmlprofilerdata.cpp index f0c6302c06..4ed1a434a3 100644 --- a/tools/qmlprofiler/qmlprofilerdata.cpp +++ b/tools/qmlprofiler/qmlprofilerdata.cpp @@ -107,14 +107,17 @@ struct QmlRangeEventStartInstance { qint64 duration; union { int frameRate; + int inputType; qint64 numericData1; }; union { int animationCount; + int inputA; qint64 numericData2; }; union { int threadId; + int inputB; qint64 numericData3; }; qint64 numericData4; @@ -366,23 +369,36 @@ void QmlProfilerData::addMemoryEvent(QQmlProfilerDefinitions::MemoryType type, q d->startInstanceList.append(rangeEventStartInstance); } -void QmlProfilerData::addInputEvent(QQmlProfilerDefinitions::EventType type, qint64 time) +void QmlProfilerData::addInputEvent(QQmlProfilerDefinitions::InputEventType type, qint64 time, + int a, int b) { setState(AcquiringData); - QString eventHashStr = QString::fromLatin1("Input:%1").arg(type); + QQmlProfilerDefinitions::EventType eventType; + switch (type) { + case QQmlProfilerDefinitions::InputKeyPress: + case QQmlProfilerDefinitions::InputKeyRelease: + case QQmlProfilerDefinitions::InputKeyUnknown: + eventType = QQmlProfilerDefinitions::Key; + break; + default: + eventType = QQmlProfilerDefinitions::Mouse; + break; + } + + QString eventHashStr = QString::fromLatin1("Input:%1").arg(eventType); QmlRangeEventData *newEvent; if (d->eventDescriptions.contains(eventHashStr)) { newEvent = d->eventDescriptions[eventHashStr]; } else { - newEvent = new QmlRangeEventData(QString(), type, eventHashStr, QmlEventLocation(), + newEvent = new QmlRangeEventData(QString(), eventType, eventHashStr, QmlEventLocation(), QString(), QQmlProfilerDefinitions::Event, QQmlProfilerDefinitions::MaximumRangeType); d->eventDescriptions.insert(eventHashStr, newEvent); } - d->startInstanceList.append(QmlRangeEventStartInstance(time, -1, 0, 0, 0, newEvent)); + d->startInstanceList.append(QmlRangeEventStartInstance(time, -1, type, a, b, newEvent)); } void QmlProfilerData::computeQmlTime() @@ -567,13 +583,23 @@ bool QmlProfilerData::save(const QString &filename) QString::number(event.duration)); stream.writeAttribute(QStringLiteral("eventIndex"), QString::number( d->eventDescriptions.keys().indexOf(event.data->eventHashStr))); - if (event.data->message == QQmlProfilerDefinitions::Event && - event.data->detailType == QQmlProfilerDefinitions::AnimationFrame) { - // special: animation frame - stream.writeAttribute(QStringLiteral("framerate"), QString::number(event.frameRate)); - stream.writeAttribute(QStringLiteral("animationcount"), - QString::number(event.animationCount)); - stream.writeAttribute(QStringLiteral("thread"), QString::number(event.threadId)); + if (event.data->message == QQmlProfilerDefinitions::Event) { + if (event.data->detailType == QQmlProfilerDefinitions::AnimationFrame) { + // special: animation frame + stream.writeAttribute(QStringLiteral("framerate"), QString::number(event.frameRate)); + stream.writeAttribute(QStringLiteral("animationcount"), + QString::number(event.animationCount)); + stream.writeAttribute(QStringLiteral("thread"), QString::number(event.threadId)); + } else if (event.data->detailType == QQmlProfilerDefinitions::Key || + event.data->detailType == QQmlProfilerDefinitions::Mouse) { + // numerical value here, to keep the format a bit more compact + stream.writeAttribute(QStringLiteral("type"), + QString::number(event.inputType)); + stream.writeAttribute(QStringLiteral("data1"), + QString::number(event.inputA)); + stream.writeAttribute(QStringLiteral("data2"), + QString::number(event.inputB)); + } } else if (event.data->message == QQmlProfilerDefinitions::PixmapCacheEvent) { // special: pixmap cache event if (event.data->detailType == QQmlProfilerDefinitions::PixmapSizeKnown) { |