diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2013-11-04 16:22:10 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-04 22:46:13 +0100 |
commit | 770ab026a80a038c77eb8957902208b2f6e76427 (patch) | |
tree | f679528b6c29e1e68414c33a0d361bf40a9cce1d | |
parent | 0884802bb5a775e30555d21f071e12989fcba8c9 (diff) |
Revert "QTest: use nth_element to calculate the median"
This reverts commit 48586b2bac623605e9f300f8e5380e4f4b484dab.
This causes problems in QtCreator without anyone being able to say why.
Task-number: QTBUG-34397
Change-Id: I9ea5457724d5af8d87e0bc40e6615748daf9c04c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | src/testlib/qtestcase.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 260ace642e..e170d2a044 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1631,14 +1631,13 @@ QBenchmarkResult qMedian(const QList<QBenchmarkResult> &container) if (count == 1) return container.front(); - const int middle = count / 2; - QList<QBenchmarkResult> containerCopy = container; - const QList<QBenchmarkResult>::iterator begin = containerCopy.begin(), mid = begin + middle, end = containerCopy.end(); - std::nth_element(begin, mid, end); + std::sort(containerCopy.begin(), containerCopy.end()); + + const int middle = count / 2; // ### handle even-sized containers here by doing an aritmetic mean of the two middle items. - return *mid; + return containerCopy.at(middle); } struct QTestDataSetter |