mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-07 01:35:25 +08:00
qt 6.5.1 original
This commit is contained in:
13
tests/benchmarks/corelib/io/qtemporaryfile/CMakeLists.txt
Normal file
13
tests/benchmarks/corelib/io/qtemporaryfile/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## tst_bench_qtemporaryfile Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_benchmark(tst_bench_qtemporaryfile
|
||||
SOURCES
|
||||
tst_bench_qtemporaryfile.cpp
|
||||
LIBRARIES
|
||||
Qt::Test
|
||||
)
|
@ -0,0 +1,64 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#include <QDebug>
|
||||
#include <QIODevice>
|
||||
#include <QFile>
|
||||
#include <QString>
|
||||
#include <QTemporaryFile>
|
||||
#include <qtest.h>
|
||||
|
||||
class tst_QTemporaryFile : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void openclose_data();
|
||||
void openclose();
|
||||
void readwrite_data() { openclose_data(); }
|
||||
void readwrite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
void tst_QTemporaryFile::openclose_data()
|
||||
{
|
||||
QTest::addColumn<qint64>("amount");
|
||||
QTest::newRow("100") << qint64(100);
|
||||
QTest::newRow("1000") << qint64(1000);
|
||||
QTest::newRow("10000") << qint64(10000);
|
||||
}
|
||||
|
||||
void tst_QTemporaryFile::openclose()
|
||||
{
|
||||
QFETCH(qint64, amount);
|
||||
|
||||
QBENCHMARK {
|
||||
for (qint64 i = 0; i < amount; ++i) {
|
||||
QTemporaryFile file;
|
||||
file.open();
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QTemporaryFile::readwrite()
|
||||
{
|
||||
QFETCH(qint64, amount);
|
||||
|
||||
const int dataSize = 4096;
|
||||
QByteArray data;
|
||||
data.fill('a', dataSize);
|
||||
QBENCHMARK {
|
||||
for (qint64 i = 0; i < amount; ++i) {
|
||||
QTemporaryFile file;
|
||||
file.open();
|
||||
file.write(data);
|
||||
file.seek(0);
|
||||
file.read(dataSize);
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QTemporaryFile)
|
||||
|
||||
#include "tst_bench_qtemporaryfile.moc"
|
Reference in New Issue
Block a user