From a522652fc919f3bff8772bb2b7bd291d10eb4f12 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Mon, 20 Jul 2009 18:44:56 +0200 Subject: Add low level POSIX bench on Windows Merge-request: 702 Reviewed-by: Olivier Goffart --- tests/benchmarks/qdir/tst_qdir.cpp | 37 +++++++++++++++++++++++++++++++------ 1 file 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 -#include -#include -#include -#include +#ifdef Q_OS_WIN +# include +#else +# include +# include +# include +# include +#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) -- cgit v0.12