diff options
author | Tobias Koenig <tobias.koenig@kdab.com> | 2016-01-19 17:45:42 +0100 |
---|---|---|
committer | Tobias Koenig <tobias.koenig@kdab.com> | 2016-01-21 18:57:04 +0000 |
commit | 24d851dcd2a140bf346343c5eb64d944cd1c1a87 (patch) | |
tree | c298808e3d9b41fe36a88106bc957d5b6e1910aa /src/concurrent/qtconcurrentiteratekernel.h | |
parent | c3850dd636ab24c251942fde63f22d8f5b3a639e (diff) |
Avoid heap allocations in Median class
Create a MedianDouble class and V2 version of BlockSizeManager, which
use a fixed size array of double (since we always use 7 elements
to calculate the median anyway).
Change-Id: Ife90b90336a9a8c037b90726dee4cd2a1b8b6cd9
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/concurrent/qtconcurrentiteratekernel.h')
-rw-r--r-- | src/concurrent/qtconcurrentiteratekernel.h | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/concurrent/qtconcurrentiteratekernel.h b/src/concurrent/qtconcurrentiteratekernel.h index 32acf03338..40e2c6c115 100644 --- a/src/concurrent/qtconcurrentiteratekernel.h +++ b/src/concurrent/qtconcurrentiteratekernel.h @@ -82,6 +82,32 @@ private: Q_DISABLE_COPY(BlockSizeManager) }; +// ### Qt6: Replace BlockSizeManager with V2 implementation +class Q_CONCURRENT_EXPORT BlockSizeManagerV2 +{ +public: + explicit BlockSizeManagerV2(int iterationCount); + + void timeBeforeUser(); + void timeAfterUser(); + int blockSize(); + +private: + inline bool blockSizeMaxed() + { + return (m_blockSize >= maxBlockSize); + } + + const int maxBlockSize; + qint64 beforeUser; + qint64 afterUser; + MedianDouble controlPartElapsed; + MedianDouble userPartElapsed; + int m_blockSize; + + Q_DISABLE_COPY(BlockSizeManagerV2) +}; + template <typename T> class ResultReporter { @@ -190,7 +216,7 @@ public: ThreadFunctionResult forThreadFunction() { - BlockSizeManager blockSizeManager(iterationCount); + BlockSizeManagerV2 blockSizeManager(iterationCount); ResultReporter<T> resultReporter(this); for(;;) { |