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 <christian.kandeler@qt.io>
This commit is contained in:
Ulf Hermann
2017-02-21 11:45:33 +01:00
parent bf69eb9467
commit 2b75df2139

View File

@@ -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) {
eventBuffer.append(event);
}
emit qmlEventsLoaded(eventBuffer);
eventBufferIndex = 0;
}
}
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();
}