tst_bench_QImageReader: add a benchmark for raw QFatoryLoader operations
This is Eirik's QtCore-only QTBUG-114253 reproducer added to the nearest fitting existing benchmark. Done-with: Eirik Aavitsland <eirik.aavitsland@qt.io> Pick-to: 6.6 6.5 6.2 5.15 Task-number: QTBUG-114253 Change-Id: Iba68bedebae908af497267860e2b230db269787e Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
parent
6c60117d01
commit
a5bcb41678
@ -9,6 +9,7 @@ qt_internal_add_benchmark(tst_bench_qimagereader
|
|||||||
SOURCES
|
SOURCES
|
||||||
tst_bench_qimagereader.cpp
|
tst_bench_qimagereader.cpp
|
||||||
LIBRARIES
|
LIBRARIES
|
||||||
|
Qt::CorePrivate
|
||||||
Qt::Gui
|
Qt::Gui
|
||||||
Qt::Test
|
Qt::Test
|
||||||
)
|
)
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <QImageWriter>
|
#include <QImageWriter>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
|
#include <QtCore/private/qfactoryloader_p.h>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@ -30,6 +31,9 @@ public slots:
|
|||||||
void initTestCase();
|
void initTestCase();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void rawFactoryLoader_keyMap();
|
||||||
|
void rawFactoryLoader_instance();
|
||||||
|
|
||||||
void readImage_data();
|
void readImage_data();
|
||||||
void readImage();
|
void readImage();
|
||||||
|
|
||||||
@ -45,6 +49,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
QList< QPair<QString, QByteArray> > images; // filename, format
|
QList< QPair<QString, QByteArray> > images; // filename, format
|
||||||
QString prefix;
|
QString prefix;
|
||||||
|
QFactoryLoader m_loader{QImageIOHandlerFactoryInterface_iid, "/imageformats"};
|
||||||
};
|
};
|
||||||
|
|
||||||
tst_bench_QImageReader::tst_bench_QImageReader()
|
tst_bench_QImageReader::tst_bench_QImageReader()
|
||||||
@ -81,6 +86,30 @@ void tst_bench_QImageReader::initTestCase()
|
|||||||
QFAIL("Can't find images directory!");
|
QFAIL("Can't find images directory!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_bench_QImageReader::rawFactoryLoader_keyMap()
|
||||||
|
{
|
||||||
|
if (m_loader.keyMap().isEmpty())
|
||||||
|
QSKIP("No image plugins found.");
|
||||||
|
|
||||||
|
QBENCHMARK {
|
||||||
|
[[maybe_unused]] auto r = m_loader.keyMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_bench_QImageReader::rawFactoryLoader_instance()
|
||||||
|
{
|
||||||
|
if (m_loader.keyMap().isEmpty())
|
||||||
|
QSKIP("No image plugins found.");
|
||||||
|
|
||||||
|
const auto numInstances = m_loader.keyMap().uniqueKeys().size();
|
||||||
|
|
||||||
|
QBENCHMARK {
|
||||||
|
for (int i = 0; i < numInstances; ++i)
|
||||||
|
delete m_loader.instance(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void tst_bench_QImageReader::readImage_data()
|
void tst_bench_QImageReader::readImage_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QString>("fileName");
|
QTest::addColumn<QString>("fileName");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user