aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-09-17 13:34:38 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-10-30 20:07:45 +0000
commitcdb0ddeffd1bab0afd4c763e44431b11c8e8e0b0 (patch)
treea131686359acd1f9bdc378fa5523a8d726397e6d /tools
parentb5cd093559d71fb28c9c8e9cffc415e1aa1e7b11 (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')
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp6
-rw-r--r--tools/qmlprofiler/qmlprofilerclient.cpp20
-rw-r--r--tools/qmlprofiler/qmlprofilerclient.h2
-rw-r--r--tools/qmlprofiler/qmlprofilerdata.cpp48
-rw-r--r--tools/qmlprofiler/qmlprofilerdata.h2
5 files changed, 62 insertions, 16 deletions
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index 2aa4afe4f6..04d0ede54a 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -112,8 +112,10 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) :
qint64)),
&m_profilerData, SLOT(addMemoryEvent(QQmlProfilerDefinitions::MemoryType,qint64,
qint64)));
- connect(&m_qmlProfilerClient, SIGNAL(inputEvent(QQmlProfilerDefinitions::EventType,qint64)),
- &m_profilerData, SLOT(addInputEvent(QQmlProfilerDefinitions::EventType,qint64)));
+ connect(&m_qmlProfilerClient, SIGNAL(inputEvent(QQmlProfilerDefinitions::InputEventType,qint64,
+ int,int)),
+ &m_profilerData, SLOT(addInputEvent(QQmlProfilerDefinitions::InputEventType,qint64,int,
+ int)));
connect(&m_qmlProfilerClient, SIGNAL(complete()), &m_profilerData, SLOT(complete()));
diff --git a/tools/qmlprofiler/qmlprofilerclient.cpp b/tools/qmlprofiler/qmlprofilerclient.cpp
index 28cb64066d..5e63529d35 100644
--- a/tools/qmlprofiler/qmlprofilerclient.cpp
+++ b/tools/qmlprofiler/qmlprofilerclient.cpp
@@ -157,7 +157,25 @@ void QmlProfilerClient::messageReceived(const QByteArray &data)
event == QQmlProfilerDefinitions::Mouse) {
if (!(d->features & one << QQmlProfilerDefinitions::ProfileInputEvents))
return;
- emit this->inputEvent((QQmlProfilerDefinitions::EventType)event, time);
+
+ int type;
+ if (!stream.atEnd()) {
+ stream >> type;
+ } else {
+ type = (event == QQmlProfilerDefinitions::Key) ?
+ QQmlProfilerDefinitions::InputKeyUnknown :
+ QQmlProfilerDefinitions::InputMouseUnknown;
+ }
+
+ int a = 0;
+ if (!stream.atEnd())
+ stream >> a;
+
+ int b = 0;
+ if (!stream.atEnd())
+ stream >> b;
+
+ emit inputEvent(static_cast<QQmlProfilerDefinitions::InputEventType>(type), time, a, b);
}
} else if (messageType == QQmlProfilerDefinitions::Complete) {
emit complete();
diff --git a/tools/qmlprofiler/qmlprofilerclient.h b/tools/qmlprofiler/qmlprofilerclient.h
index daaf624d7d..bc267c7c88 100644
--- a/tools/qmlprofiler/qmlprofilerclient.h
+++ b/tools/qmlprofiler/qmlprofilerclient.h
@@ -68,7 +68,7 @@ signals:
void pixmapCache(QQmlProfilerDefinitions::PixmapEventType, qint64 time,
const QmlEventLocation &location, int width, int height, int refCount);
void memoryAllocation(QQmlProfilerDefinitions::MemoryType type, qint64 time, qint64 amount);
- void inputEvent(QQmlProfilerDefinitions::EventType, qint64 time);
+ void inputEvent(QQmlProfilerDefinitions::InputEventType type, qint64 time, int a, int b);
void complete();
void enabledChanged(bool enabled);
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) {
diff --git a/tools/qmlprofiler/qmlprofilerdata.h b/tools/qmlprofiler/qmlprofilerdata.h
index e038fa6884..b931409917 100644
--- a/tools/qmlprofiler/qmlprofilerdata.h
+++ b/tools/qmlprofiler/qmlprofilerdata.h
@@ -83,7 +83,7 @@ public slots:
void addPixmapCacheEvent(QQmlProfilerDefinitions::PixmapEventType type, qint64 time,
const QmlEventLocation &location, int width, int height, int refcount);
void addMemoryEvent(QQmlProfilerDefinitions::MemoryType type, qint64 time, qint64 size);
- void addInputEvent(QQmlProfilerDefinitions::EventType type, qint64 time);
+ void addInputEvent(QQmlProfilerDefinitions::InputEventType type, qint64 time, int a, int b);
void complete();
bool save(const QString &filename);