summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp5
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/main.cpp5
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp5
-rw-r--r--tests/benchmarks/corelib/io/qfile/main.cpp26
-rw-r--r--tests/benchmarks/corelib/io/qfileinfo/main.cpp4
-rw-r--r--tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp4
-rw-r--r--tests/benchmarks/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp174
-rw-r--r--tests/benchmarks/corelib/thread/thread.pro1
-rw-r--r--tests/benchmarks/corelib/tools/qhash/main.cpp42
-rw-r--r--tests/benchmarks/corelib/tools/qhash/main.h10
-rw-r--r--tests/benchmarks/corelib/tools/qhash/outofline.cpp10
-rw-r--r--tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.cpp20
-rw-r--r--tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.h6
-rw-r--r--tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp140
-rw-r--r--tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp8
15 files changed, 304 insertions, 156 deletions
diff --git a/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp b/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp
index 49672a90bf..b2380b0e58 100644
--- a/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp
+++ b/tests/benchmarks/corelib/io/qdir/10000/bench_qdir_10000.cpp
@@ -176,7 +176,12 @@ private slots:
wcscat(appendedPath, L"\\*");
WIN32_FIND_DATA fd;
+#ifndef Q_OS_WINRT
HANDLE hSearch = FindFirstFileW(appendedPath, &fd);
+#else
+ HANDLE hSearch = FindFirstFileEx(appendedPath, FindExInfoStandard, &fd,
+ FindExSearchNameMatch, NULL, FIND_FIRST_EX_LARGE_FETCH);
+#endif
QVERIFY(hSearch != INVALID_HANDLE_VALUE);
QBENCHMARK {
diff --git a/tests/benchmarks/corelib/io/qdiriterator/main.cpp b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
index 5188658bdb..691e822379 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/main.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
@@ -106,7 +106,12 @@ static int posix_helper(const wchar_t *dirpath)
wchar_t appendedPath[MAX_PATH];
wcscpy(appendedPath, dirpath);
wcscat(appendedPath, L"\\*");
+#ifndef Q_OS_WINRT
hSearch = FindFirstFile(appendedPath, &fd);
+#else
+ hSearch = FindFirstFileEx(appendedPath, FindExInfoStandard, &fd,
+ FindExSearchNameMatch, NULL, FIND_FIRST_EX_LARGE_FETCH);
+#endif
appendedPath[origDirPathLength] = 0;
if (hSearch == INVALID_HANDLE_VALUE) {
diff --git a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
index bb4a921fc7..82bca1541d 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp
@@ -230,7 +230,12 @@ void QFileSystemIteratorPrivate::pushSubDirectory(const QByteArray &path)
wchar_t szSearchPath[MAX_PATH];
QString::fromLatin1(path).toWCharArray(szSearchPath);
wcscat(szSearchPath, L"\\*");
+#ifndef Q_OS_WINRT
HANDLE dir = FindFirstFile(szSearchPath, &m_fileSearchResult);
+#else
+ HANDLE dir = FindFirstFileEx(szSearchPath, FindExInfoStandard, &m_fileSearchResult,
+ FindExSearchLimitToDirectories, NULL, FIND_FIRST_EX_LARGE_FETCH);
+#endif
m_bFirstSearchResult = true;
#else
DIR *dir = ::opendir(path.constData());
diff --git a/tests/benchmarks/corelib/io/qfile/main.cpp b/tests/benchmarks/corelib/io/qfile/main.cpp
index 0beffebfb7..e0ae29fbee 100644
--- a/tests/benchmarks/corelib/io/qfile/main.cpp
+++ b/tests/benchmarks/corelib/io/qfile/main.cpp
@@ -310,7 +310,11 @@ void tst_qfile::readBigFile()
// ensure we don't account string conversion
wchar_t* cfilename = (wchar_t*)filename.utf16();
+#ifndef Q_OS_WINRT
hndl = CreateFile(cfilename, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
+#else
+ hndl = CreateFile2(cfilename, GENERIC_READ, 0, OPEN_EXISTING, 0);
+#endif
Q_ASSERT(hndl);
wchar_t* nativeBuffer = new wchar_t[BUFSIZE];
DWORD numberOfBytesRead;
@@ -319,7 +323,12 @@ void tst_qfile::readBigFile()
do {
ReadFile(hndl, nativeBuffer, blockSize, &numberOfBytesRead, NULL);
} while(numberOfBytesRead != 0);
+#ifndef Q_OS_WINRT
SetFilePointer(hndl, 0, NULL, FILE_BEGIN);
+#else
+ LARGE_INTEGER offset = { 0 };
+ SetFilePointerEx(hndl, offset, NULL, FILE_BEGIN);
+#endif
}
delete[] nativeBuffer;
CloseHandle(hndl);
@@ -400,11 +409,20 @@ void tst_qfile::seek()
// ensure we don't account string conversion
wchar_t* cfilename = (wchar_t*)filename.utf16();
+#ifndef Q_OS_WINRT
hndl = CreateFile(cfilename, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
+#else
+ hndl = CreateFile2(cfilename, GENERIC_READ, 0, OPEN_EXISTING, 0);
+#endif
Q_ASSERT(hndl);
QBENCHMARK {
i=(i+1)%sp_size;
+#ifndef Q_OS_WINRT
SetFilePointer(hndl, seekpos[i], NULL, 0);
+#else
+ LARGE_INTEGER offset = { seekpos[i] };
+ SetFilePointerEx(hndl, offset, NULL, FILE_BEGIN);
+#endif
}
CloseHandle(hndl);
#else
@@ -489,7 +507,11 @@ void tst_qfile::open()
wchar_t* cfilename = (wchar_t*)filename.utf16();
QBENCHMARK {
+#ifndef Q_OS_WINRT
hndl = CreateFile(cfilename, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
+#else
+ hndl = CreateFile2(cfilename, GENERIC_READ, 0, OPEN_EXISTING, 0);
+#endif
Q_ASSERT(hndl);
CloseHandle(hndl);
}
@@ -698,7 +720,11 @@ void tst_qfile::readSmallFiles()
// ensure we don't account string conversion
wchar_t* cfilename = (wchar_t*)filename.utf16();
+#ifndef Q_OS_WINRT
hndl = CreateFile(cfilename, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
+#else
+ hndl = CreateFile2(cfilename, GENERIC_READ, 0, OPEN_EXISTING, 0);
+#endif
Q_ASSERT(hndl);
wchar_t* nativeBuffer = new wchar_t[BUFSIZE];
DWORD numberOfBytesRead;
diff --git a/tests/benchmarks/corelib/io/qfileinfo/main.cpp b/tests/benchmarks/corelib/io/qfileinfo/main.cpp
index 594e5b7478..de1aaea177 100644
--- a/tests/benchmarks/corelib/io/qfileinfo/main.cpp
+++ b/tests/benchmarks/corelib/io/qfileinfo/main.cpp
@@ -54,7 +54,7 @@ class qfileinfo : public QObject
private slots:
void existsTemporary();
void existsStatic();
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
void symLinkTargetPerformanceLNK();
void symLinkTargetPerformanceMounpoint();
#endif
@@ -84,7 +84,7 @@ void qfileinfo::existsStatic()
QBENCHMARK { QFileInfo::exists(appPath); }
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
void qfileinfo::symLinkTargetPerformanceLNK()
{
QVERIFY(QFile::link("file","link.lnk"));
diff --git a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp
index 47227ef630..52c60f9484 100644
--- a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp
+++ b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp
@@ -95,7 +95,11 @@ void NativeMutexUnlock(NativeMutexType *mutex)
typedef CRITICAL_SECTION NativeMutexType;
void NativeMutexInitialize(NativeMutexType *mutex)
{
+#ifndef Q_OS_WINRT
InitializeCriticalSection(mutex);
+#else
+ InitializeCriticalSectionEx(mutex, 0, 0);
+#endif
}
void NativeMutexDestroy(NativeMutexType *mutex)
{
diff --git a/tests/benchmarks/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp b/tests/benchmarks/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp
index 55967b9215..d5919ebe5a 100644
--- a/tests/benchmarks/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp
+++ b/tests/benchmarks/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp
@@ -55,156 +55,88 @@ public:
}
private slots:
- void oscillate_data();
- void oscillate();
-
- void thrash_data();
- void thrash();
-
-public:
- static QWaitCondition local, remote;
- enum Turn {LocalTurn, RemoteTurn};
- static Turn turn;
+ void oscillate_mutex_data();
+ void oscillate_mutex();
+ void oscillate_writelock_data();
+ void oscillate_writelock();
};
-QWaitCondition tst_QWaitCondition::local;
-QWaitCondition tst_QWaitCondition::remote;
-tst_QWaitCondition::Turn tst_QWaitCondition::turn = tst_QWaitCondition::LocalTurn;
+int turn;
+const int threadCount = 10;
+QWaitCondition cond;
+
+template <class Mutex, class Locker>
class OscillateThread : public QThread
{
public:
- bool m_done;
- bool m_useMutex;
- unsigned long m_timeout;
- bool m_wakeOne;
- int count;
-
- OscillateThread(bool useMutex, unsigned long timeout, bool wakeOne)
- : m_done(false), m_useMutex(useMutex), m_timeout(timeout), m_wakeOne(wakeOne)
- {}
+ Mutex *mutex;
+ int m_threadid;
+ int timeout;
+
void run()
{
- QMutex mtx;
- QReadWriteLock rwl;
- count = 0;
-
- forever {
- if (m_done)
- break;
- if (m_useMutex) {
- mtx.lock();
- while (tst_QWaitCondition::turn == tst_QWaitCondition::LocalTurn)
- tst_QWaitCondition::remote.wait(&mtx, m_timeout);
- mtx.unlock();
- } else {
- rwl.lockForWrite();
- while (tst_QWaitCondition::turn == tst_QWaitCondition::LocalTurn)
- tst_QWaitCondition::remote.wait(&rwl, m_timeout);
- rwl.unlock();
+ for (int count = 0; count < 5000; ++count) {
+
+ Locker lock(mutex);
+ while (m_threadid != turn) {
+ cond.wait(mutex, timeout);
}
- tst_QWaitCondition::turn = tst_QWaitCondition::LocalTurn;
- if (m_wakeOne)
- tst_QWaitCondition::local.wakeOne();
- else
- tst_QWaitCondition::local.wakeAll();
- count++;
+ turn = (turn+1) % threadCount;
+ cond.wakeAll();
}
}
};
-void tst_QWaitCondition::oscillate_data()
-{
- QTest::addColumn<bool>("useMutex");
- QTest::addColumn<unsigned long>("timeout");
- QTest::addColumn<bool>("wakeOne");
-
- QTest::newRow("mutex, timeout, one") << true << 1000ul << true;
- QTest::newRow("readWriteLock, timeout, one") << false << 1000ul << true;
- QTest::newRow("mutex, timeout, all") << true << 1000ul << false;
- QTest::newRow("readWriteLock, timeout, all") << false << 1000ul << false;
- QTest::newRow("mutex, forever, one") << true << ULONG_MAX << true;
- QTest::newRow("readWriteLock, forever, one") << false << ULONG_MAX << true;
- QTest::newRow("mutex, forever, all") << true << ULONG_MAX << false;
- QTest::newRow("readWriteLock, forever, all") << false << ULONG_MAX << false;
-}
-
-void tst_QWaitCondition::oscillate()
-{
- QMutex mtx;
- QReadWriteLock rwl;
+template <class Mutex, class Locker>
+void oscillate(unsigned long timeout) {
- QFETCH(bool, useMutex);
- QFETCH(unsigned long, timeout);
- QFETCH(bool, wakeOne);
-
- turn = LocalTurn;
- OscillateThread thrd(useMutex, timeout, wakeOne);
- thrd.start();
+ OscillateThread<Mutex, Locker> thrd[threadCount];
+ Mutex m;
+ for (int i = 0; i < threadCount; ++i) {
+ thrd[i].mutex = &m;
+ thrd[i].m_threadid = i;
+ thrd[i].timeout = timeout;
+ }
QBENCHMARK {
- if (useMutex)
- mtx.lock();
- else
- rwl.lockForWrite();
- turn = RemoteTurn;
- if (wakeOne)
- remote.wakeOne();
- else
- remote.wakeAll();
- if (useMutex) {
- while (turn == RemoteTurn)
- local.wait(&mtx, timeout);
- mtx.unlock();
- } else {
- while (turn == RemoteTurn)
- local.wait(&rwl, timeout);
- rwl.unlock();
+ for (int i = 0; i < threadCount; ++i) {
+ thrd[i].start();
+ }
+ for (int i = 0; i < threadCount; ++i) {
+ thrd[i].wait();
}
}
- thrd.m_done = true;
- remote.wakeAll();
- thrd.wait();
-
- QCOMPARE(0, 0);
}
-void tst_QWaitCondition::thrash_data()
+void tst_QWaitCondition::oscillate_mutex_data()
{
- oscillate_data();
+ QTest::addColumn<unsigned long>("timeout");
+
+ QTest::newRow("0") << 0ul;
+ QTest::newRow("1") << 1ul;
+ QTest::newRow("1000") << 1000ul;
+ QTest::newRow("forever") << ULONG_MAX;
}
-void tst_QWaitCondition::thrash()
+void tst_QWaitCondition::oscillate_mutex()
{
- QMutex mtx;
- mtx.lock();
-
- QFETCH(bool, useMutex);
QFETCH(unsigned long, timeout);
- QFETCH(bool, wakeOne);
-
- turn = LocalTurn;
- OscillateThread thrd(useMutex, timeout, wakeOne);
- thrd.start();
- local.wait(&mtx, 1000ul);
- mtx.unlock();
-
- QBENCHMARK {
- turn = RemoteTurn;
- if (wakeOne)
- remote.wakeOne();
- else
- remote.wakeAll();
- }
+ oscillate<QMutex, QMutexLocker>(timeout);
+}
- thrd.m_done = true;
- turn = RemoteTurn;
- remote.wakeAll();
- thrd.wait();
+void tst_QWaitCondition::oscillate_writelock_data()
+{
+ oscillate_mutex_data();
+}
- QCOMPARE(0, 0);
+void tst_QWaitCondition::oscillate_writelock()
+{
+ QFETCH(unsigned long, timeout);
+ oscillate<QReadWriteLock, QWriteLocker>(timeout);
}
+
QTEST_MAIN(tst_QWaitCondition)
#include "tst_qwaitcondition.moc"
diff --git a/tests/benchmarks/corelib/thread/thread.pro b/tests/benchmarks/corelib/thread/thread.pro
index d7f65a911d..4e602ceb4e 100644
--- a/tests/benchmarks/corelib/thread/thread.pro
+++ b/tests/benchmarks/corelib/thread/thread.pro
@@ -3,3 +3,4 @@ SUBDIRS = \
qmutex \
qthreadstorage \
qthreadpool \
+ qwaitcondition \
diff --git a/tests/benchmarks/corelib/tools/qhash/main.cpp b/tests/benchmarks/corelib/tools/qhash/main.cpp
index a39ced19fe..b173724aed 100644
--- a/tests/benchmarks/corelib/tools/qhash/main.cpp
+++ b/tests/benchmarks/corelib/tools/qhash/main.cpp
@@ -55,13 +55,28 @@ class tst_QHash : public QObject
private slots:
void initTestCase();
+ void qhash_current_data() { data(); }
+ void qhash_current() { qhash_template<QString>(); }
+ void qhash_qt50_data() { data(); }
+ void qhash_qt50() { qhash_template<Qt50String>(); }
void qhash_qt4_data() { data(); }
- void qhash_qt4();
- void javaString_data() { data(); }
- void javaString();
+ void qhash_qt4() { qhash_template<Qt4String>(); }
+ void qhash_javaString_data() { data(); }
+ void qhash_javaString() { qhash_template<JavaString>(); }
+
+ void hashing_current_data() { data(); }
+ void hashing_current() { hashing_template<QString>(); }
+ void hashing_qt50_data() { data(); }
+ void hashing_qt50() { hashing_template<Qt50String>(); }
+ void hashing_qt4_data() { data(); }
+ void hashing_qt4() { hashing_template<Qt4String>(); }
+ void hashing_javaString_data() { data(); }
+ void hashing_javaString() { hashing_template<JavaString>(); }
private:
void data();
+ template <typename String> void qhash_template();
+ template <typename String> void hashing_template();
QStringList smallFilePaths;
QStringList uuids;
@@ -76,7 +91,7 @@ private:
void tst_QHash::initTestCase()
{
// small list of file paths
- QFile smallPathsData("paths_small_data.txt");
+ QFile smallPathsData(QFINDTESTDATA("paths_small_data.txt"));
QVERIFY(smallPathsData.open(QIODevice::ReadOnly));
smallFilePaths = QString::fromLatin1(smallPathsData.readAll()).split(QLatin1Char('\n'));
QVERIFY(!smallFilePaths.isEmpty());
@@ -133,12 +148,12 @@ void tst_QHash::data()
QTest::newRow("numbers") << numbers;
}
-void tst_QHash::qhash_qt4()
+template <typename String> void tst_QHash::qhash_template()
{
QFETCH(QStringList, items);
- QHash<Qt4String, int> hash;
+ QHash<String, int> hash;
- QList<Qt4String> realitems;
+ QList<String> realitems;
foreach (const QString &s, items)
realitems.append(s);
@@ -149,23 +164,22 @@ void tst_QHash::qhash_qt4()
}
}
-void tst_QHash::javaString()
+template <typename String> void tst_QHash::hashing_template()
{
+ // just the hashing function
QFETCH(QStringList, items);
- QHash<JavaString, int> hash;
- QList<JavaString> realitems;
+ QVector<String> realitems;
+ realitems.reserve(items.size());
foreach (const QString &s, items)
realitems.append(s);
QBENCHMARK {
- for (int i = 0, n = realitems.size(); i != n; ++i) {
- hash[realitems.at(i)] = i;
- }
+ for (int i = 0, n = realitems.size(); i != n; ++i)
+ (void)qHash(realitems.at(i));
}
}
-
QTEST_MAIN(tst_QHash)
#include "main.moc"
diff --git a/tests/benchmarks/corelib/tools/qhash/main.h b/tests/benchmarks/corelib/tools/qhash/main.h
index bd3f0db12d..86a1a3d09b 100644
--- a/tests/benchmarks/corelib/tools/qhash/main.h
+++ b/tests/benchmarks/corelib/tools/qhash/main.h
@@ -51,6 +51,16 @@ QT_BEGIN_NAMESPACE
uint qHash(const Qt4String &);
QT_END_NAMESPACE
+struct Qt50String : QString
+{
+ Qt50String() {}
+ Qt50String(const QString &s) : QString(s) {}
+};
+
+QT_BEGIN_NAMESPACE
+uint qHash(const Qt50String &, uint seed = 0);
+QT_END_NAMESPACE
+
struct JavaString : QString
{
diff --git a/tests/benchmarks/corelib/tools/qhash/outofline.cpp b/tests/benchmarks/corelib/tools/qhash/outofline.cpp
index 9ccfc11224..3a2278503d 100644
--- a/tests/benchmarks/corelib/tools/qhash/outofline.cpp
+++ b/tests/benchmarks/corelib/tools/qhash/outofline.cpp
@@ -57,6 +57,16 @@ uint qHash(const Qt4String &str)
return h;
}
+uint qHash(const Qt50String &key, uint seed)
+{
+ const QChar *p = key.unicode();
+ int len = key.size();
+ uint h = seed;
+ for (int i = 0; i < len; ++i)
+ h = 31 * h + p[i].unicode();
+ return h;
+}
+
// The Java's hashing algorithm for strings is a variation of D. J. Bernstein
// hashing algorithm appeared here http://cr.yp.to/cdb/cdb.txt
// and informally known as DJB33XX - DJB's 33 Times Xor.
diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.cpp
index 4d6a8712fd..949965adf2 100644
--- a/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.cpp
+++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.cpp
@@ -94,25 +94,25 @@ void ChipTester::paintEvent(QPaintEvent *event)
{
QGraphicsView::paintEvent(event);
if (++npaints == 50)
- eventLoop.quit();
+ eventLoop.quit();
}
void ChipTester::timerEvent(QTimerEvent *)
{
switch (operation) {
case Rotate360:
- rotate(1);
- break;
+ rotate(1);
+ break;
case ZoomInOut: {
- qreal s = 0.05 + (npaints / 20.0);
- setTransform(QTransform().scale(s, s));
- break;
+ qreal s = 0.05 + (npaints / 20.0);
+ setTransform(QTransform().scale(s, s));
+ break;
}
case Translate: {
- int offset = horizontalScrollBar()->minimum()
- + (npaints % (horizontalScrollBar()->maximum() - horizontalScrollBar()->minimum()));
- horizontalScrollBar()->setValue(offset);
- break;
+ int offset = horizontalScrollBar()->minimum()
+ + (npaints % (horizontalScrollBar()->maximum() - horizontalScrollBar()->minimum()));
+ horizontalScrollBar()->setValue(offset);
+ break;
}
}
}
diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.h b/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.h
index 4e5b436f8d..38133f6078 100644
--- a/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.h
+++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.h
@@ -57,9 +57,9 @@ class ChipTester : public QGraphicsView
Q_OBJECT
public:
enum Operation {
- Rotate360,
- ZoomInOut,
- Translate
+ Rotate360,
+ ZoomInOut,
+ Translate
};
ChipTester(QWidget *parent = 0);
diff --git a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
index fd12c89e80..eda46a1df0 100644
--- a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
+++ b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp
@@ -42,28 +42,39 @@
#include <qtest.h>
#include <QImage>
+Q_DECLARE_METATYPE(QImage::Format)
class tst_QImageConversion : public QObject
{
Q_OBJECT
private slots:
- void convertRgb888ToRGB32_data();
- void convertRgb888ToRGB32();
+ void convertRgb888ToRgb32_data();
+ void convertRgb888ToRgb32();
+
+ void convertRgb32ToRgb888_data();
+ void convertRgb32ToRgb888();
+
+ void convertGeneric_data();
+ void convertGeneric();
private:
QImage generateImageRgb888(int width, int height);
+ QImage generateImageRgb16(int width, int height);
+ QImage generateImageRgb32(int width, int height);
+ QImage generateImageArgb32(int width, int height);
};
-void tst_QImageConversion::convertRgb888ToRGB32_data()
+void tst_QImageConversion::convertRgb888ToRgb32_data()
{
QTest::addColumn<QImage>("inputImage");
+
// height = 5000 to get interesting timing.
// 3 pixels wide -> smaller than regular vector of 128bits
QTest::newRow("width: 3px; height: 5000px;") << generateImageRgb888(3, 5000);
// 8 pixels wide -> potential for 2 vectors
- QTest::newRow("width: 8px; height: 5000px;") << generateImageRgb888(3, 5000);
+ QTest::newRow("width: 8px; height: 5000px;") << generateImageRgb888(8, 5000);
// 16 pixels, minimum for the SSSE3 implementation
QTest::newRow("width: 16px; height: 5000px;") << generateImageRgb888(16, 5000);
@@ -72,10 +83,10 @@ void tst_QImageConversion::convertRgb888ToRGB32_data()
QTest::newRow("width: 50px; height: 5000px;") << generateImageRgb888(50, 5000);
// 2000 pixels -> typical values for pictures
- QTest::newRow("width: 2000px; height: 5000px;") << generateImageRgb888(2000, 5000);
+ QTest::newRow("width: 2000px; height: 2000px;") << generateImageRgb888(2000, 2000);
}
-void tst_QImageConversion::convertRgb888ToRGB32()
+void tst_QImageConversion::convertRgb888ToRgb32()
{
QFETCH(QImage, inputImage);
@@ -87,6 +98,76 @@ void tst_QImageConversion::convertRgb888ToRGB32()
}
}
+void tst_QImageConversion::convertRgb32ToRgb888_data()
+{
+ QTest::addColumn<QImage>("inputImage");
+ // height = 5000 to get interesting timing.
+
+ // 3 pixels wide -> smaller than regular vector of 128bits
+ QTest::newRow("width: 3px; height: 5000px;") << generateImageRgb32(3, 5000);
+
+ // 8 pixels wide -> potential for 2 vectors
+ QTest::newRow("width: 8px; height: 5000px;") << generateImageRgb32(8, 5000);
+
+ // 16 pixels, minimum for the SSSE3 implementation
+ QTest::newRow("width: 16px; height: 5000px;") << generateImageRgb32(16, 5000);
+
+ // 50 pixels, more realistic use case
+ QTest::newRow("width: 50px; height: 5000px;") << generateImageRgb32(50, 5000);
+
+ // 2000 pixels -> typical values for pictures
+ QTest::newRow("width: 2000px; height: 2000px;") << generateImageRgb32(2000, 2000);
+}
+
+void tst_QImageConversion::convertRgb32ToRgb888()
+{
+ QFETCH(QImage, inputImage);
+
+ QBENCHMARK {
+ volatile QImage output = inputImage.convertToFormat(QImage::Format_RGB888);
+ // we need the volatile and the following to make sure the compiler does not do
+ // anything stupid :)
+ (void)output;
+ }
+}
+
+
+void tst_QImageConversion::convertGeneric_data()
+{
+ QTest::addColumn<QImage>("inputImage");
+ QTest::addColumn<QImage::Format>("outputFormat");
+ QImage rgb16 = generateImageRgb16(1000, 1000);
+ QImage rgb32 = generateImageRgb32(1000, 1000);
+ QImage argb32 = generateImageArgb32(1000, 1000);
+
+ QTest::newRow("rgb16 -> rgb32") << rgb16 << QImage::Format_RGB32;
+ QTest::newRow("rgb16 -> rgb888") << rgb16 << QImage::Format_RGB888;
+ QTest::newRow("rgb16 -> rgb666") << rgb16 << QImage::Format_RGB666;
+ QTest::newRow("rgb16 -> rgb555") << rgb16 << QImage::Format_RGB555;
+
+ QTest::newRow("rgb32 -> rgb16") << rgb32 << QImage::Format_RGB16;
+ QTest::newRow("rgb32 -> rgb888") << rgb32 << QImage::Format_RGB888;
+ QTest::newRow("rgb32 -> rgb666") << rgb32 << QImage::Format_RGB666;
+ QTest::newRow("rgb32 -> rgb555") << rgb32 << QImage::Format_RGB555;
+
+ QTest::newRow("argb32 -> rgba8888") << argb32 << QImage::Format_RGBA8888;
+ QTest::newRow("argb32 -> rgb888") << argb32 << QImage::Format_RGB888;
+ QTest::newRow("argb32 -> rgb666") << argb32 << QImage::Format_RGB666;
+ QTest::newRow("argb32 -> argb8565pm") << argb32 << QImage::Format_ARGB8565_Premultiplied;
+ QTest::newRow("argb32 -> argb4444pm") << argb32 << QImage::Format_ARGB4444_Premultiplied;
+}
+
+void tst_QImageConversion::convertGeneric()
+{
+ QFETCH(QImage, inputImage);
+ QFETCH(QImage::Format, outputFormat);
+
+ QBENCHMARK {
+ QImage output = inputImage.convertToFormat(outputFormat);
+ output.constBits();
+ }
+}
+
/*
Fill a RGB888 image with "random" pixel values.
*/
@@ -103,5 +184,52 @@ QImage tst_QImageConversion::generateImageRgb888(int width, int height)
return image;
}
+/*
+ Fill a RGB16 image with "random" pixel values.
+ */
+QImage tst_QImageConversion::generateImageRgb16(int width, int height)
+{
+ QImage image(width, height, QImage::Format_RGB16);
+ const int byteWidth = width * 2;
+
+ for (int y = 0; y < image.height(); ++y) {
+ uchar *scanline = image.scanLine(y);
+ for (int x = 0; x < byteWidth; ++x)
+ scanline[x] = x ^ y;
+ }
+ return image;
+}
+
+/*
+ Fill a RGB32 image with "random" pixel values.
+ */
+QImage tst_QImageConversion::generateImageRgb32(int width, int height)
+{
+ QImage image(width, height, QImage::Format_RGB32);
+
+ for (int y = 0; y < image.height(); ++y) {
+ QRgb *scanline = (QRgb*)image.scanLine(y);
+ for (int x = 0; x < width; ++x)
+ scanline[x] = qRgb(x, y, x ^ y);
+ }
+ return image;
+}
+
+/*
+ Fill a ARGB32 image with "random" pixel values.
+ */
+QImage tst_QImageConversion::generateImageArgb32(int width, int height)
+{
+ QImage image(width, height, QImage::Format_ARGB32);
+ const int byteWidth = width * 4;
+
+ for (int y = 0; y < image.height(); ++y) {
+ uchar *scanline = image.scanLine(y);
+ for (int x = 0; x < byteWidth; ++x)
+ scanline[x] = x ^ y;
+ }
+ return image;
+}
+
QTEST_MAIN(tst_QImageConversion)
#include "tst_qimageconversion.moc"
diff --git a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp
index 5ed6651052..fb95ecb5b4 100644
--- a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp
+++ b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp
@@ -88,7 +88,9 @@ void tst_QTcpServer::initTestCase_data()
QTest::addColumn<int>("proxyType");
QTest::newRow("WithoutProxy") << false << 0;
+#ifndef QT_NO_NETWORKPROXY
QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy);
+#endif
}
void tst_QTcpServer::initTestCase()
@@ -100,16 +102,22 @@ void tst_QTcpServer::init()
{
QFETCH_GLOBAL(bool, setProxy);
if (setProxy) {
+#ifndef QT_NO_NETWORKPROXY
QFETCH_GLOBAL(int, proxyType);
if (proxyType == QNetworkProxy::Socks5Proxy) {
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
}
+#else // !QT_NO_NETWORKPROXY
+ QSKIP("No proxy support");
+#endif // QT_NO_NETWORKPROXY
}
}
void tst_QTcpServer::cleanup()
{
+#ifndef QT_NO_NETWORKPROXY
QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy);
+#endif
}
//----------------------------------------------------------------------------------