PerfProfiler: When saving is canceled, don't flush the buffer anymore

Flushing the compression buffer can be expensive. If the save operation
is canceled we know that the user wants the process to stop ASAP. So,
rather discard all remaining buffered data in that case.

Change-Id: Id77ec6fabb5a26690a7d2d8596f25f44d3185253
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Ulf Hermann
2019-01-07 14:32:21 +01:00
parent 034c514c3a
commit b2638f8ac3

View File

@@ -376,6 +376,7 @@ public:
device()->reset(); device()->reset();
} }
void clear() { m_content.clear(); }
int length() const { return m_content.length(); } int length() const { return m_content.length(); }
private: private:
@@ -492,12 +493,16 @@ void PerfProfilerTraceFile::writeToDevice()
++i; ++i;
if (bufferStream.length() > (1 << 25)) { if (bufferStream.length() > (1 << 25)) {
updateProgress(progress + (remainingProgress * i / traceManager->numEvents())); if (updateProgress(progress + (remainingProgress * i / traceManager->numEvents())))
bufferStream.flush(); bufferStream.flush();
else
bufferStream.clear();
} }
}, nullptr, [&](){ }, nullptr, [&](){
if (updateProgress(progress += remainingProgress)) if (updateProgress(progress += remainingProgress))
bufferStream.flush(); bufferStream.flush();
else
bufferStream.clear();
}, [this](const QString &message) { }, [this](const QString &message) {
fail(message); fail(message);
}, future()); }, future());