Commit 2b75df21 authored by Ulf Hermann's avatar Ulf Hermann

QmlProfiler: Simplify buffer handling when loading trace

The inserting of events into the buffer is not the bottleneck here.
The book keeping is probably more expensive than just always using
all the events contained in a chuck from the file for one batch.

Change-Id: I75a936fdf9e3a1d9675b44d67b98f14594f87ffd
Reviewed-by: Christian Kandeler's avatarChristian Kandeler <christian.kandeler@qt.io>
parent bf69eb94
......@@ -243,15 +243,13 @@ void QmlProfilerFileReader::loadQzt(QIODevice *device)
updateProgress(device);
}
const int eventBufferLength = 1024;
QVector<QmlEvent> eventBuffer(eventBufferLength);
int eventBufferIndex = 0;
QVector<QmlEvent> eventBuffer;
while (!stream.atEnd() && !isCanceled()) {
stream >> data;
buffer.setData(qUncompress(data));
buffer.open(QIODevice::ReadOnly);
while (!buffer.atEnd() && !isCanceled()) {
QmlEvent &event = eventBuffer[eventBufferIndex];
QmlEvent event;
bufferStream >> event;
if (bufferStream.status() == QDataStream::Ok) {
if (event.typeIndex() >= m_eventTypes.length()) {
......@@ -267,11 +265,10 @@ void QmlProfilerFileReader::loadQzt(QIODevice *device)
} else {
Q_UNREACHABLE();
}
if (++eventBufferIndex == eventBufferLength) {
emit qmlEventsLoaded(eventBuffer);
eventBufferIndex = 0;
}
eventBuffer.append(event);
}
emit qmlEventsLoaded(eventBuffer);
eventBuffer.clear();
buffer.close();
updateProgress(device);
}
......@@ -279,7 +276,6 @@ void QmlProfilerFileReader::loadQzt(QIODevice *device)
if (isCanceled()) {
emit canceled();
} else {
eventBuffer.resize(eventBufferIndex);
emit qmlEventsLoaded(eventBuffer);
emit success();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment