2 #include <QCoreApplication>
6 #include <QImageReader>
9 #include <lib/imageformats/imageformats.h>
11 const int ITERATIONS
= 2;
12 const QSize
SCALED_SIZE(1280, 800);
15 static void bench(QIODevice
* device
, const QString
& outputName
) {
18 for (int iteration
=0; iteration
<ITERATIONS
; ++iteration
) {
19 qDebug() << "Iteration:" << iteration
;
21 device
->open(QIODevice::ReadOnly
);
22 QImageReader
reader(device
);
23 QSize size
= reader
.size();
24 size
.scale(SCALED_SIZE
, Qt::KeepAspectRatio
);
25 reader
.setScaledSize(size
);
26 QImage img
= reader
.read();
29 if (iteration
== ITERATIONS
- 1) {
30 qDebug() << "time:" << chrono
.elapsed();
31 img
.save(outputName
, "png");
37 int main(int argc
, char** argv
) {
38 QCoreApplication
app(argc
, argv
);
40 qDebug() << "Usage: imageloadbench <file.jpg>";
44 QString fileName
= QString::fromUtf8(argv
[1]);
47 if (!file
.open(QIODevice::ReadOnly
)) {
48 qDebug() << QString("Could not open '%1'").arg(fileName
);
51 QByteArray data
= file
.readAll();
52 QBuffer
buffer(&data
);
54 qDebug() << "Using Qt loader";
55 bench(&buffer
, "qt.png");
56 Gwenview::ImageFormats::registerPlugins();
57 qDebug() << "Using Gwenview loader";
58 bench(&buffer
, "gv.png");