diff options
Diffstat (limited to 'tests/benchmarks/corelib/tools/qringbuffer')
4 files changed, 51 insertions, 84 deletions
diff --git a/tests/benchmarks/corelib/tools/qringbuffer/CMakeLists.txt b/tests/benchmarks/corelib/tools/qringbuffer/CMakeLists.txt index fd10411ff3..322fbbb83c 100644 --- a/tests/benchmarks/corelib/tools/qringbuffer/CMakeLists.txt +++ b/tests/benchmarks/corelib/tools/qringbuffer/CMakeLists.txt @@ -1,16 +1,14 @@ -# Generated from qringbuffer.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_bench_qringbuffer Binary: ##################################################################### -qt_add_benchmark(tst_bench_qringbuffer +qt_internal_add_benchmark(tst_bench_qringbuffer SOURCES - main.cpp - PUBLIC_LIBRARIES + tst_bench_qringbuffer.cpp + LIBRARIES Qt::CorePrivate Qt::Test ) - -#### Keys ignored in scope 1:.:.:qringbuffer.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/benchmarks/corelib/tools/qringbuffer/main.cpp b/tests/benchmarks/corelib/tools/qringbuffer/main.cpp deleted file mode 100644 index fad30a4e34..0000000000 --- a/tests/benchmarks/corelib/tools/qringbuffer/main.cpp +++ /dev/null @@ -1,71 +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 <private/qringbuffer_p.h> -#include <QByteArray> - -#include <qtest.h> - -class tst_qringbuffer : public QObject -{ - Q_OBJECT -private slots: - void reserveAndRead(); - void free(); -}; - -void tst_qringbuffer::reserveAndRead() -{ - QRingBuffer ringBuffer; - QBENCHMARK { - for (qint64 i = 1; i < 256; ++i) - ringBuffer.reserve(i); - - for (qint64 i = 1; i < 256; ++i) - ringBuffer.read(0, i); - } -} - -void tst_qringbuffer::free() -{ - QRingBuffer ringBuffer; - QBENCHMARK { - ringBuffer.reserve(4096); - ringBuffer.reserve(2048); - ringBuffer.append(QByteArray("01234", 5)); - - ringBuffer.free(1); - ringBuffer.free(4096); - ringBuffer.free(48); - ringBuffer.free(2000); - } -} - -QTEST_MAIN(tst_qringbuffer) - -#include "main.moc" diff --git a/tests/benchmarks/corelib/tools/qringbuffer/qringbuffer.pro b/tests/benchmarks/corelib/tools/qringbuffer/qringbuffer.pro deleted file mode 100644 index 69750865b5..0000000000 --- a/tests/benchmarks/corelib/tools/qringbuffer/qringbuffer.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE = app -CONFIG += benchmark -QT = core-private testlib - -TARGET = tst_bench_qringbuffer -SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/qringbuffer/tst_bench_qringbuffer.cpp b/tests/benchmarks/corelib/tools/qringbuffer/tst_bench_qringbuffer.cpp new file mode 100644 index 0000000000..f352cd56a9 --- /dev/null +++ b/tests/benchmarks/corelib/tools/qringbuffer/tst_bench_qringbuffer.cpp @@ -0,0 +1,46 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <private/qringbuffer_p.h> +#include <QByteArray> + +#include <qtest.h> + +class tst_QRingBuffer : public QObject +{ + Q_OBJECT +private slots: + void reserveAndRead(); + void free(); +}; + +void tst_QRingBuffer::reserveAndRead() +{ + QRingBuffer ringBuffer; + QBENCHMARK { + for (qint64 i = 1; i < 256; ++i) + ringBuffer.reserve(i); + + for (qint64 i = 1; i < 256; ++i) + ringBuffer.read(0, i); + } +} + +void tst_QRingBuffer::free() +{ + QRingBuffer ringBuffer; + QBENCHMARK { + ringBuffer.reserve(4096); + ringBuffer.reserve(2048); + ringBuffer.append(QByteArray("01234", 5)); + + ringBuffer.free(1); + ringBuffer.free(4096); + ringBuffer.free(48); + ringBuffer.free(2000); + } +} + +QTEST_MAIN(tst_QRingBuffer) + +#include "tst_bench_qringbuffer.moc" |