From b2638f8ac39f5416d614bc2e88e413b0cfefd7af Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 7 Jan 2019 14:32:21 +0100 Subject: [PATCH] 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 --- src/plugins/perfprofiler/perfprofilertracefile.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/perfprofiler/perfprofilertracefile.cpp b/src/plugins/perfprofiler/perfprofilertracefile.cpp index 597df213fd1..9b9eb3dc31c 100644 --- a/src/plugins/perfprofiler/perfprofilertracefile.cpp +++ b/src/plugins/perfprofiler/perfprofilertracefile.cpp @@ -376,6 +376,7 @@ public: device()->reset(); } + void clear() { m_content.clear(); } int length() const { return m_content.length(); } private: @@ -492,12 +493,16 @@ void PerfProfilerTraceFile::writeToDevice() ++i; if (bufferStream.length() > (1 << 25)) { - updateProgress(progress + (remainingProgress * i / traceManager->numEvents())); - bufferStream.flush(); + if (updateProgress(progress + (remainingProgress * i / traceManager->numEvents()))) + bufferStream.flush(); + else + bufferStream.clear(); } }, nullptr, [&](){ if (updateProgress(progress += remainingProgress)) bufferStream.flush(); + else + bufferStream.clear(); }, [this](const QString &message) { fail(message); }, future());