From caa5a20479bd58fda4380181691f772a1f3c1da4 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Fri, 2 Mar 2018 16:36:06 +0200 Subject: Make a benchmark out of tst_QObjectPerformance::emitToManyReceivers The test has been flaky on top of QEMU. The test is clearly a sort of manually rolled benchmark, not a regular autotest. Remove the test and replace it with a benchmark in QObjectBenchmark. Task-number: QTBUG-66823 Task-number: QTBUG-66216 Change-Id: I7a48293023f32141eed6fea50fbb63af18933a8f Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/other/other.pro | 2 - tests/auto/other/qobjectperformance/.gitignore | 1 - .../qobjectperformance/qobjectperformance.pro | 7 -- .../qobjectperformance/tst_qobjectperformance.cpp | 110 --------------------- tests/benchmarks/corelib/kernel/qobject/main.cpp | 24 +++++ 5 files changed, 24 insertions(+), 120 deletions(-) delete mode 100644 tests/auto/other/qobjectperformance/.gitignore delete mode 100644 tests/auto/other/qobjectperformance/qobjectperformance.pro delete mode 100644 tests/auto/other/qobjectperformance/tst_qobjectperformance.cpp diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 4119a40279..ea2e1dabf2 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -16,7 +16,6 @@ SUBDIRS=\ qcomplextext \ qfocusevent \ qnetworkaccessmanager_and_qprogressdialog \ - qobjectperformance \ qobjectrace \ qsharedpointer_and_qwidget \ qprocess_and_guieventloop \ @@ -44,7 +43,6 @@ SUBDIRS=\ lancelot \ networkselftest \ qnetworkaccessmanager_and_qprogressdialog \ - qobjectperformance cross_compile: SUBDIRS -= \ atwrapper \ diff --git a/tests/auto/other/qobjectperformance/.gitignore b/tests/auto/other/qobjectperformance/.gitignore deleted file mode 100644 index 028ca89aad..0000000000 --- a/tests/auto/other/qobjectperformance/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qobjectperformance diff --git a/tests/auto/other/qobjectperformance/qobjectperformance.pro b/tests/auto/other/qobjectperformance/qobjectperformance.pro deleted file mode 100644 index 189f8eeb2a..0000000000 --- a/tests/auto/other/qobjectperformance/qobjectperformance.pro +++ /dev/null @@ -1,7 +0,0 @@ -CONFIG += testcase -TARGET = tst_qobjectperformance -SOURCES += tst_qobjectperformance.cpp - -QT = core network testlib - - diff --git a/tests/auto/other/qobjectperformance/tst_qobjectperformance.cpp b/tests/auto/other/qobjectperformance/tst_qobjectperformance.cpp deleted file mode 100644 index cbff6b7caf..0000000000 --- a/tests/auto/other/qobjectperformance/tst_qobjectperformance.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** 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-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include - -#include - -#include - -class tst_QObjectPerformance : public QObject -{ - Q_OBJECT - -public: - -private slots: - void emitToManyReceivers(); -}; - -class SimpleSenderObject : public QObject -{ - Q_OBJECT - -signals: - void signal(); - -public: - void emitSignal() - { - emit signal(); - } -}; - -class SimpleReceiverObject : public QObject -{ - Q_OBJECT - -public slots: - void slot() - { - } -}; - -void tst_QObjectPerformance::emitToManyReceivers() -{ - // ensure that emission times remain mostly linear as the number of receivers increase - - SimpleSenderObject sender; - int elapsed = 0; - const int increase = 3000; - const int base = 5000; - - for (int i = 0; i < 4; ++i) { - const int size = base + i * increase; - const double increaseRatio = double(size) / (double)(size - increase); - - QList receivers; - for (int k = 0; k < size; ++k) { - SimpleReceiverObject *receiver = new SimpleReceiverObject; - QObject::connect(&sender, SIGNAL(signal()), receiver, SLOT(slot())); - receivers.append(receiver); - } - - QTime timer; - timer.start(); - sender.emitSignal(); - int e = timer.elapsed(); - - if (elapsed > 1) { - qDebug() << size << "receivers, elapsed time" << e << "compared to previous time" << elapsed; - QVERIFY(double(e) / double(elapsed) <= increaseRatio * 2.0); - } else { - qDebug() << size << "receivers, elapsed time" << e << "cannot be compared to previous, unmeasurable time"; - } - elapsed = e; - - qDeleteAll(receivers); - receivers.clear(); - } -} - - -QTEST_MAIN(tst_QObjectPerformance) -#include "tst_qobjectperformance.moc" diff --git a/tests/benchmarks/corelib/kernel/qobject/main.cpp b/tests/benchmarks/corelib/kernel/qobject/main.cpp index c11b13b7ea..04ca69ad3b 100644 --- a/tests/benchmarks/corelib/kernel/qobject/main.cpp +++ b/tests/benchmarks/corelib/kernel/qobject/main.cpp @@ -43,6 +43,8 @@ Q_OBJECT private slots: void signal_slot_benchmark(); void signal_slot_benchmark_data(); + void signal_many_receivers(); + void signal_many_receivers_data(); void qproperty_benchmark_data(); void qproperty_benchmark(); void dynamic_property_benchmark(); @@ -127,6 +129,28 @@ void QObjectBenchmark::signal_slot_benchmark() } } +void QObjectBenchmark::signal_many_receivers_data() +{ + QTest::addColumn("receiverCount"); + QTest::newRow("100 receivers") << 100; + QTest::newRow("1 000 receivers") << 1000; + QTest::newRow("10 000 receivers") << 10000; +} + +void QObjectBenchmark::signal_many_receivers() +{ + QFETCH(int, receiverCount); + Object sender; + std::vector receivers(receiverCount); + + for (Object &receiver : receivers) + QObject::connect(&sender, &Object::signal0, &receiver, &Object::slot0); + + QBENCHMARK { + sender.emitSignal0(); + } +} + void QObjectBenchmark::qproperty_benchmark_data() { QTest::addColumn("name"); -- cgit v1.2.3