diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2020-04-09 13:23:42 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2020-08-05 09:17:11 +0200 |
commit | 07b008425acb1f550c3e6e96e2bd6033fe86976a (patch) | |
tree | 19d1f4552f2766418b002dd51e7c22cf958aee9d /tests/benchmarks | |
parent | c8db3115a212de3c2ef01f20891ef6545f2f3850 (diff) | |
download | qtbase-07b008425acb1f550c3e6e96e2bd6033fe86976a.tar.gz |
Privately introducing QDecompressHelper for network purposes
To support streaming decompression in QNAM.
Will also be used to refactor existing decompression code in QNAM.
Task-number: QTBUG-83269
Change-Id: Iecf3e359734163f15686c949f75d41fa4794a00e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/network/access/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tests/benchmarks/network/access/access.pro | 5 | ||||
-rw-r--r-- | tests/benchmarks/network/access/qdecompresshelper/.prev_CMakeLists.txt | 19 | ||||
-rw-r--r-- | tests/benchmarks/network/access/qdecompresshelper/50mb.txt.gz | bin | 0 -> 50922 bytes | |||
-rw-r--r-- | tests/benchmarks/network/access/qdecompresshelper/CMakeLists.txt | 19 | ||||
-rw-r--r-- | tests/benchmarks/network/access/qdecompresshelper/main.cpp | 89 | ||||
-rw-r--r-- | tests/benchmarks/network/access/qdecompresshelper/qdecompresshelper.pro | 8 |
7 files changed, 143 insertions, 0 deletions
diff --git a/tests/benchmarks/network/access/CMakeLists.txt b/tests/benchmarks/network/access/CMakeLists.txt index 58f72cd248..3069505252 100644 --- a/tests/benchmarks/network/access/CMakeLists.txt +++ b/tests/benchmarks/network/access/CMakeLists.txt @@ -4,3 +4,6 @@ add_subdirectory(qfile_vs_qnetworkaccessmanager) add_subdirectory(qnetworkreply) add_subdirectory(qnetworkreply_from_cache) add_subdirectory(qnetworkdiskcache) +if(QT_FEATURE_private_tests) + add_subdirectory(qdecompresshelper) +endif() diff --git a/tests/benchmarks/network/access/access.pro b/tests/benchmarks/network/access/access.pro index 46b7a5f44d..fed262601b 100644 --- a/tests/benchmarks/network/access/access.pro +++ b/tests/benchmarks/network/access/access.pro @@ -4,3 +4,8 @@ SUBDIRS = \ qnetworkreply \ qnetworkreply_from_cache \ qnetworkdiskcache + +qtConfig(private_tests): \ + SUBDIRS += \ + qdecompresshelper \ + diff --git a/tests/benchmarks/network/access/qdecompresshelper/.prev_CMakeLists.txt b/tests/benchmarks/network/access/qdecompresshelper/.prev_CMakeLists.txt new file mode 100644 index 0000000000..cec7aad7b2 --- /dev/null +++ b/tests/benchmarks/network/access/qdecompresshelper/.prev_CMakeLists.txt @@ -0,0 +1,19 @@ +# Generated from qdecompresshelper.pro. + +##################################################################### +## qdecompresshelper Binary: +##################################################################### + +qt_add_executable(qdecompresshelper + SOURCES + main.cpp + DEFINES + SRC_DIR="${CMAKE_CURRENT_SOURCE_DIR}" + PUBLIC_LIBRARIES + Qt::NetworkPrivate + Qt::Test +) + +#### Keys ignored in scope 1:.:.:qdecompresshelper.pro:<TRUE>: +# TEMPLATE = "app" +# _REQUIREMENTS = "qtConfig(private_tests)" diff --git a/tests/benchmarks/network/access/qdecompresshelper/50mb.txt.gz b/tests/benchmarks/network/access/qdecompresshelper/50mb.txt.gz Binary files differnew file mode 100644 index 0000000000..523830dd00 --- /dev/null +++ b/tests/benchmarks/network/access/qdecompresshelper/50mb.txt.gz diff --git a/tests/benchmarks/network/access/qdecompresshelper/CMakeLists.txt b/tests/benchmarks/network/access/qdecompresshelper/CMakeLists.txt new file mode 100644 index 0000000000..af7676b561 --- /dev/null +++ b/tests/benchmarks/network/access/qdecompresshelper/CMakeLists.txt @@ -0,0 +1,19 @@ +# Generated from qdecompresshelper.pro. + +##################################################################### +## qdecompresshelper Binary: +##################################################################### + +qt_add_executable(qdecompresshelper + SOURCES + main.cpp + DEFINES + SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR} # special case + PUBLIC_LIBRARIES + Qt::NetworkPrivate + Qt::Test +) + +#### Keys ignored in scope 1:.:.:decompresshelper.pro:<TRUE>: +# TEMPLATE = "app" +# _REQUIREMENTS = "qtConfig(private_tests)" diff --git a/tests/benchmarks/network/access/qdecompresshelper/main.cpp b/tests/benchmarks/network/access/qdecompresshelper/main.cpp new file mode 100644 index 0000000000..a16a9d8c32 --- /dev/null +++ b/tests/benchmarks/network/access/qdecompresshelper/main.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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 <QtNetwork/private/qdecompresshelper_p.h> + +#include <QtTest/QTest> + +class tst_QDecompressHelper : public QObject +{ + Q_OBJECT +private slots: + + void decompress_data(); + void decompress(); +}; + +void tst_QDecompressHelper::decompress_data() +{ + QTest::addColumn<QByteArray>("encoding"); + QTest::addColumn<QString>("fileName"); + + QString srcDir = QStringLiteral(QT_STRINGIFY(SRC_DIR)); + srcDir = QDir::fromNativeSeparators(srcDir); + if (!srcDir.endsWith("/")) + srcDir += "/"; + + bool dataAdded = false; +#ifndef QT_NO_COMPRESS + QTest::addRow("gzip") << QByteArray("gzip") << srcDir + QString("50mb.txt.gz"); + dataAdded = true; +#endif + if (!dataAdded) + QSKIP("There's no decompression support"); +} + +void tst_QDecompressHelper::decompress() +{ + QFETCH(QByteArray, encoding); + QFETCH(QString, fileName); + + QFile file { fileName }; + QVERIFY(file.open(QIODevice::ReadOnly)); + QBENCHMARK { + file.seek(0); + QDecompressHelper helper; + helper.setEncoding(encoding); + QVERIFY(helper.isValid()); + + helper.feed(file.readAll()); + + qsizetype bytes = 0; + while (helper.hasData()) { + QByteArray out(64 * 1024, Qt::Uninitialized); + qsizetype bytesRead = helper.read(out.data(), out.size()); + bytes += bytesRead; + } + + QCOMPARE(bytes, 50 * 1024 * 1024); + } +} + +QTEST_MAIN(tst_QDecompressHelper) + +#include "main.moc" diff --git a/tests/benchmarks/network/access/qdecompresshelper/qdecompresshelper.pro b/tests/benchmarks/network/access/qdecompresshelper/qdecompresshelper.pro new file mode 100644 index 0000000000..f87442260e --- /dev/null +++ b/tests/benchmarks/network/access/qdecompresshelper/qdecompresshelper.pro @@ -0,0 +1,8 @@ +requires(qtConfig(private_tests)) +TEMPLATE = app +QT = network-private testlib + +SOURCES = main.cpp +CONFIG += release + +DEFINES += SRC_DIR="$$PWD" |