QmlDebug: Support multiple messages per packet

Sending multiple messages in a packet can dramatically reduce the
protocol overhead. QmlProfiler messages are only 26 bytes long, on
average. The "CanvasFrameRate" name, which is prepended to each packet
is 15 bytes long, not counting extra bytes for length information.

Change-Id: I67087cefc1f6bd72ba960414672b048015179869
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2016-03-03 11:52:30 +01:00
parent e75b88cd7c
commit 3a2691c663

View File

@@ -122,7 +122,8 @@ void QmlDebugConnection::socketConnected()
{
Q_D(QmlDebugConnection);
QPacket pack(d->currentDataStreamVersion);
pack << serverId << 0 << protocolVersion << d->plugins.keys() << d->maximumDataStreamVersion;
pack << serverId << 0 << protocolVersion << d->plugins.keys() << d->maximumDataStreamVersion
<< true; // We accept multiple messages per packet
d->protocol->send(pack.data());
d->flush();
}
@@ -254,14 +255,17 @@ void QmlDebugConnection::protocolReadyRead()
qWarning() << "QML Debug Client: Unknown control message id" << op;
}
} else {
QByteArray message;
pack >> message;
QHash<QString, QmlDebugClient *>::Iterator iter = d->plugins.find(name);
if (iter == d->plugins.end())
if (iter == d->plugins.end()) {
qWarning() << "QML Debug Client: Message received for missing plugin" << name;
else
(*iter)->messageReceived(message);
} else {
QmlDebugClient *client = *iter;
QByteArray message;
while (!pack.atEnd()) {
pack >> message;
client->messageReceived(message);
}
}
}
}
}