From f939e7ea7375dbc051c81abf7b24c6fd5304cbbb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 13 Oct 2016 09:18:05 +0200 Subject: Testlib: Move classes inheriting QBenchmarkMeasurerBase to separate header QBenchmarkTimeMeasurer uses the 3rd party header cycle_p.h which may include windows.h on Windows (32bit). This can cause clashes in qmltest, which uses QBenchmarkMeasurerBase. Move the derived classes to a separate header to prevent this. Change-Id: I943a11c32a575594e6e79e722e8809b42de35092 Reviewed-by: Maurice Kalinowski Reviewed-by: Lars Knoll --- src/testlib/qbenchmark.cpp | 1 + src/testlib/qbenchmarkmeasurement.cpp | 2 +- src/testlib/qbenchmarkmeasurement_p.h | 36 ------------- src/testlib/qbenchmarktimemeasurers_p.h | 96 +++++++++++++++++++++++++++++++++ src/testlib/testlib.pro | 1 + 5 files changed, 99 insertions(+), 37 deletions(-) create mode 100644 src/testlib/qbenchmarktimemeasurers_p.h (limited to 'src') diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp index c884d5d740..c933a16c35 100644 --- a/src/testlib/qbenchmark.cpp +++ b/src/testlib/qbenchmark.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include diff --git a/src/testlib/qbenchmarkmeasurement.cpp b/src/testlib/qbenchmarkmeasurement.cpp index ac4d75ce3b..228ab15f99 100644 --- a/src/testlib/qbenchmarkmeasurement.cpp +++ b/src/testlib/qbenchmarkmeasurement.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include +#include #include #include #include diff --git a/src/testlib/qbenchmarkmeasurement_p.h b/src/testlib/qbenchmarkmeasurement_p.h index 1444439e11..8dbfd4b618 100644 --- a/src/testlib/qbenchmarkmeasurement_p.h +++ b/src/testlib/qbenchmarkmeasurement_p.h @@ -51,8 +51,6 @@ // We mean it. // -#include -#include #include QT_BEGIN_NAMESPACE @@ -73,40 +71,6 @@ public: virtual QTest::QBenchmarkMetric metricType() = 0; }; -class QBenchmarkTimeMeasurer : public QBenchmarkMeasurerBase -{ -public: - void start(); - qint64 checkpoint(); - qint64 stop(); - bool isMeasurementAccepted(qint64 measurement); - int adjustIterationCount(int sugestion); - int adjustMedianCount(int suggestion); - bool needsWarmupIteration(); - QTest::QBenchmarkMetric metricType(); -private: - QElapsedTimer time; -}; - -#ifdef HAVE_TICK_COUNTER // defined in 3rdparty/cycle_p.h - -class QBenchmarkTickMeasurer : public QBenchmarkMeasurerBase -{ -public: - void start(); - qint64 checkpoint(); - qint64 stop(); - bool isMeasurementAccepted(qint64 measurement); - int adjustIterationCount(int); - int adjustMedianCount(int suggestion); - bool needsWarmupIteration(); - QTest::QBenchmarkMetric metricType(); -private: - CycleCounterTicks startTicks; -}; - -#endif - QT_END_NAMESPACE #endif // QBENCHMARKMEASUREMENT_P_H diff --git a/src/testlib/qbenchmarktimemeasurers_p.h b/src/testlib/qbenchmarktimemeasurers_p.h new file mode 100644 index 0000000000..e5ffb1157d --- /dev/null +++ b/src/testlib/qbenchmarktimemeasurers_p.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBENCHMARKTIMEMEASURERS_P_H +#define QBENCHMARKTIMEMEASURERS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QBenchmarkTimeMeasurer : public QBenchmarkMeasurerBase +{ +public: + void start(); + qint64 checkpoint(); + qint64 stop(); + bool isMeasurementAccepted(qint64 measurement); + int adjustIterationCount(int sugestion); + int adjustMedianCount(int suggestion); + bool needsWarmupIteration(); + QTest::QBenchmarkMetric metricType(); +private: + QElapsedTimer time; +}; + +#ifdef HAVE_TICK_COUNTER // defined in 3rdparty/cycle_p.h + +class QBenchmarkTickMeasurer : public QBenchmarkMeasurerBase +{ +public: + void start(); + qint64 checkpoint(); + qint64 stop(); + bool isMeasurementAccepted(qint64 measurement); + int adjustIterationCount(int); + int adjustMedianCount(int suggestion); + bool needsWarmupIteration(); + QTest::QBenchmarkMetric metricType(); +private: + CycleCounterTicks startTicks; +}; + +#endif // HAVE_TICK_COUNTER + +QT_END_NAMESPACE + +#endif // QBENCHMARKTIMEMEASURERS_P_H diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index d76dbb8c75..5b2205e875 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -14,6 +14,7 @@ QMAKE_DOCS = $$PWD/doc/qttestlib.qdocconf HEADERS = qbenchmark.h \ qbenchmark_p.h \ qbenchmarkmeasurement_p.h \ + qbenchmarktimemeasurers_p.h \ qbenchmarkvalgrind_p.h \ qbenchmarkevent_p.h \ qbenchmarkperfevents_p.h \ -- cgit v1.2.3