diff options
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/qdir/tst_qdir.cpp | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/tests/benchmarks/qdir/tst_qdir.cpp b/tests/benchmarks/qdir/tst_qdir.cpp index 6405645..edb2811 100644 --- a/tests/benchmarks/qdir/tst_qdir.cpp +++ b/tests/benchmarks/qdir/tst_qdir.cpp @@ -1,9 +1,13 @@ #include <QtTest/QtTest> -#include<dirent.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> +#ifdef Q_OS_WIN +# include <windows.h> +#else +# include <sys/stat.h> +# include <sys/types.h> +# include <dirent.h> +# include <unistd.h> +#endif class Test : public QObject{ Q_OBJECT @@ -73,10 +77,31 @@ private slots: } } } -#ifndef Q_OS_WIN + void testLowLevel() { +#ifdef Q_OS_WIN + const wchar_t *dirpath = (wchar_t*)testdir.absolutePath().utf16(); + wchar_t appendedPath[MAX_PATH]; + wcscpy(appendedPath, dirpath); + wcscat(appendedPath, L"\\*"); + + WIN32_FIND_DATA fd; + HANDLE hSearch = FindFirstFileW(appendedPath, &fd); + if (hSearch != INVALID_HANDLE_VALUE) + return; + + QBENCHMARK { + do { + + } while (FindNextFile(hSearch, &fd)); + } + FindClose(hSearch); +#else QDir testdir(QDir::tempPath() + QLatin1String("/test_speed")); DIR *dir = opendir(qPrintable(testdir.absolutePath())); + if (!dir) + return; + QVERIFY(!chdir(qPrintable(testdir.absolutePath()))); QBENCHMARK { struct dirent *item = readdir(dir); @@ -90,8 +115,8 @@ private slots: } } closedir(dir); - } #endif + } }; QTEST_MAIN(Test) |