diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2009-07-20 16:44:56 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-07-20 16:56:43 (GMT) |
commit | a522652fc919f3bff8772bb2b7bd291d10eb4f12 (patch) | |
tree | f9a1299a88e52b8a7bfa1c953bc064accc02f270 /tests/benchmarks | |
parent | a1314799a70db18d54123956b92a239bd50387a9 (diff) | |
download | Qt-a522652fc919f3bff8772bb2b7bd291d10eb4f12.zip Qt-a522652fc919f3bff8772bb2b7bd291d10eb4f12.tar.gz Qt-a522652fc919f3bff8772bb2b7bd291d10eb4f12.tar.bz2 |
Add low level POSIX bench on Windows
Merge-request: 702
Reviewed-by: Olivier Goffart <ogoffart@trolltech.com>
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) |