summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/corelib')
-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
11 files changed, 149 insertions, 137 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.