diff options
Diffstat (limited to 'tests/benchmarks')
9 files changed, 109 insertions, 123 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/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 } //---------------------------------------------------------------------------------- |