aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmlprofiler/qmlprofilertracefile.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2016-11-08 17:26:39 +0100
committerUlf Hermann <ulf.hermann@qt.io>2016-11-09 11:54:57 +0000
commitaaca50f705ac8f41f44991478fe11f9eb37fe0bd (patch)
tree6e751f25616f302526f726ad97d2f8041fda5e53 /src/plugins/qmlprofiler/qmlprofilertracefile.cpp
parenta432683e0ce7a6cace498db26ee268af1e47e7bf (diff)
QmlProfiler: Send loaded events in batches of about 1024
This significantly reduces the number of signals necessary when loading traces. The overhead of queueing those signals across threads was responsible for up to 80% of the time required to load a trace. Change-Id: I461a2ef9944b0be102a29f8ed6b2b3f2f59f3c0f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/qmlprofiler/qmlprofilertracefile.cpp')
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertracefile.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp
index 67188e32fa..ec9195bbd0 100644
--- a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp
@@ -123,7 +123,7 @@ QmlProfilerFileReader::QmlProfilerFileReader(QObject *parent) :
m_loadedFeatures(0)
{
static int meta[] = {
- qRegisterMetaType<QmlEvent>(),
+ qRegisterMetaType<QVector<QmlEvent> >(),
qRegisterMetaType<QVector<QmlEventType> >(),
qRegisterMetaType<QVector<QmlNote> >()
};
@@ -248,7 +248,9 @@ bool QmlProfilerFileReader::loadQzt(QIODevice *device)
emit notesLoaded(m_notes);
updateProgress(device);
- QmlEvent event;
+ const int eventBufferLength = 1024;
+ QVector<QmlEvent> eventBuffer(eventBufferLength);
+ int eventBufferIndex = 0;
while (!stream.atEnd()) {
stream >> data;
buffer.setData(qUncompress(data));
@@ -256,6 +258,7 @@ bool QmlProfilerFileReader::loadQzt(QIODevice *device)
while (!buffer.atEnd()) {
if (isCanceled())
return false;
+ QmlEvent &event = eventBuffer[eventBufferIndex];
bufferStream >> event;
if (bufferStream.status() == QDataStream::Ok) {
if (event.typeIndex() >= m_eventTypes.length()) {
@@ -263,7 +266,6 @@ bool QmlProfilerFileReader::loadQzt(QIODevice *device)
return false;
}
m_loadedFeatures |= (1ULL << m_eventTypes[event.typeIndex()].feature());
- emit qmlEventLoaded(event);
} else if (bufferStream.status() == QDataStream::ReadPastEnd) {
break; // Apparently EOF is a character so we end up here after the last event.
} else if (bufferStream.status() == QDataStream::ReadCorruptData) {
@@ -272,10 +274,16 @@ bool QmlProfilerFileReader::loadQzt(QIODevice *device)
} else {
Q_UNREACHABLE();
}
+ if (++eventBufferIndex == eventBufferLength) {
+ emit qmlEventsLoaded(eventBuffer);
+ eventBufferIndex = 0;
+ }
}
buffer.close();
updateProgress(device);
}
+ eventBuffer.resize(eventBufferIndex);
+ emit qmlEventsLoaded(eventBuffer);
emit success();
return true;
}
@@ -499,8 +507,7 @@ void QmlProfilerFileReader::loadEvents(QXmlStreamReader &stream)
std::sort(events.begin(), events.end(), [](const QmlEvent &a, const QmlEvent &b) {
return a.timestamp() < b.timestamp();
});
- foreach (const QmlEvent &event, events)
- emit qmlEventLoaded(event);
+ emit qmlEventsLoaded(events);
return;
}
break;