summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/benchmarks.pro4
-rw-r--r--tests/benchmarks/qdir/tst_qdir.cpp35
-rw-r--r--tests/benchmarks/qdiriterator/main.cpp2
-rw-r--r--tests/benchmarks/qdiriterator/qfilesystemiterator.cpp19
-rw-r--r--tests/benchmarks/qfile/main.cpp12
-rw-r--r--tests/benchmarks/qnetworkreply/main.cpp74
-rw-r--r--tests/benchmarks/qnetworkreply/qnetworkreply.pro13
-rw-r--r--tests/benchmarks/qquaternion/qquaternion.pro6
-rw-r--r--tests/benchmarks/qquaternion/tst_qquaternion.cpp124
-rw-r--r--tests/benchmarks/qstring/main.cpp18
-rw-r--r--tests/benchmarks/qstring/qstring.pro8
-rw-r--r--tests/benchmarks/qstring/utf-8.txt72
12 files changed, 358 insertions, 29 deletions
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro
index bc41125..bf02731 100644
--- a/tests/benchmarks/benchmarks.pro
+++ b/tests/benchmarks/benchmarks.pro
@@ -8,8 +8,10 @@ SUBDIRS = containers-associative \
qiodevice \
qpixmap \
blendbench \
- qstringlist \
+ qstring \
+ qstringlist \
qmatrix4x4 \
+ qnetworkreply \
qobject \
qrect \
qregexp \
diff --git a/tests/benchmarks/qdir/tst_qdir.cpp b/tests/benchmarks/qdir/tst_qdir.cpp
index 6405645..7977e28 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,29 @@ 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);
+ QVERIFY(hSearch == INVALID_HANDLE_VALUE);
+
+ QBENCHMARK {
+ do {
+
+ } while (FindNextFile(hSearch, &fd));
+ }
+ FindClose(hSearch);
+#else
QDir testdir(QDir::tempPath() + QLatin1String("/test_speed"));
DIR *dir = opendir(qPrintable(testdir.absolutePath()));
+ QVERIFY(dir);
+
QVERIFY(!chdir(qPrintable(testdir.absolutePath())));
QBENCHMARK {
struct dirent *item = readdir(dir);
@@ -90,8 +113,8 @@ private slots:
}
}
closedir(dir);
- }
#endif
+ }
};
QTEST_MAIN(Test)
diff --git a/tests/benchmarks/qdiriterator/main.cpp b/tests/benchmarks/qdiriterator/main.cpp
index 13128f7..1a5ffbb 100644
--- a/tests/benchmarks/qdiriterator/main.cpp
+++ b/tests/benchmarks/qdiriterator/main.cpp
@@ -107,7 +107,7 @@ static int posix_helper(const wchar_t *dirpath)
wchar_t appendedPath[MAX_PATH];
wcscpy(appendedPath, dirpath);
wcscat(appendedPath, L"\\*");
- hSearch = FindFirstFileW(appendedPath, &fd);
+ hSearch = FindFirstFile(appendedPath, &fd);
appendedPath[origDirPathLength] = 0;
if (hSearch == INVALID_HANDLE_VALUE) {
diff --git a/tests/benchmarks/qdiriterator/qfilesystemiterator.cpp b/tests/benchmarks/qdiriterator/qfilesystemiterator.cpp
index 1ef600b..47720f1 100644
--- a/tests/benchmarks/qdiriterator/qfilesystemiterator.cpp
+++ b/tests/benchmarks/qdiriterator/qfilesystemiterator.cpp
@@ -108,17 +108,6 @@
QT_BEGIN_NAMESPACE
-#ifdef Q_OS_WIN
-inline QString convertString(TCHAR* sz)
-{
-#ifdef UNICODE
- return QString::fromUtf16(sz);
-#else
- return QString::fromLocal8Bit(sz);
-#endif
-}
-#endif
-
class QFileSystemIteratorPrivate
{
public:
@@ -202,7 +191,7 @@ QFileSystemIteratorPrivate::~QFileSystemIteratorPrivate()
}
#ifdef Q_OS_WIN
-static bool isDotOrDotDot(const TCHAR* name)
+static bool isDotOrDotDot(const wchar_t* name)
{
if (name[0] == L'.' && name[1] == 0)
return true;
@@ -339,7 +328,7 @@ bool QFileSystemIteratorPrivate::advanceHelper()
if (m_entry->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
QByteArray ba = m_dirPaths.top();
ba += '\\';
- ba += convertString(m_entry->cFileName);
+ ba += QString::fromWCharArray(m_entry->cFileName);
pushSubDirectory(ba);
}
#else
@@ -634,7 +623,7 @@ QString QFileSystemIterator::fileName() const
if (d->m_currentDirShown == QFileSystemIteratorPrivate::ShowDotDotDir)
return QLatin1String("@@");
#ifdef Q_OS_WIN
- return convertString(d->m_entry->cFileName);
+ return QString::fromWCharArray(d->m_entry->cFileName);
#else
return QString::fromLocal8Bit(d->m_entry->d_name);
#endif
@@ -659,7 +648,7 @@ QString QFileSystemIterator::filePath() const
else if (d->m_entry) {
ba += '/';
#ifdef Q_OS_WIN
- ba += convertString(d->m_entry->cFileName);
+ ba += QString::fromWCharArray(d->m_entry->cFileName);
#else
ba += d->m_entry->d_name;
#endif
diff --git a/tests/benchmarks/qfile/main.cpp b/tests/benchmarks/qfile/main.cpp
index 36cd40a..f1c1e26 100644
--- a/tests/benchmarks/qfile/main.cpp
+++ b/tests/benchmarks/qfile/main.cpp
@@ -280,11 +280,11 @@ void tst_qfile::readBigFile()
HANDLE hndl;
// ensure we don't account string conversion
- TCHAR* cfilename = (TCHAR*)filename.utf16();
+ wchar_t* cfilename = (wchar_t*)filename.utf16();
hndl = CreateFile(cfilename, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
Q_ASSERT(hndl);
- TCHAR* nativeBuffer = new TCHAR[BUFSIZE];
+ wchar_t* nativeBuffer = new wchar_t[BUFSIZE];
DWORD numberOfBytesRead;
QBENCHMARK {
@@ -363,7 +363,7 @@ void tst_qfile::seek()
HANDLE hndl;
// ensure we don't account string conversion
- TCHAR* cfilename = (TCHAR*)filename.utf16();
+ wchar_t* cfilename = (wchar_t*)filename.utf16();
hndl = CreateFile(cfilename, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
Q_ASSERT(hndl);
@@ -446,7 +446,7 @@ void tst_qfile::open()
HANDLE hndl;
// ensure we don't account string conversion
- TCHAR* cfilename = (TCHAR*)filename.utf16();
+ wchar_t* cfilename = (wchar_t*)filename.utf16();
QBENCHMARK {
hndl = CreateFile(cfilename, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
@@ -625,11 +625,11 @@ void tst_qfile::readSmallFiles()
HANDLE hndl;
// ensure we don't account string conversion
- TCHAR* cfilename = (TCHAR*)filename.utf16();
+ wchar_t* cfilename = (wchar_t*)filename.utf16();
hndl = CreateFile(cfilename, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
Q_ASSERT(hndl);
- TCHAR* nativeBuffer = new TCHAR[BUFSIZE];
+ wchar_t* nativeBuffer = new wchar_t[BUFSIZE];
DWORD numberOfBytesRead;
QBENCHMARK {
do {
diff --git a/tests/benchmarks/qnetworkreply/main.cpp b/tests/benchmarks/qnetworkreply/main.cpp
new file mode 100644
index 0000000..3f1e9f7
--- /dev/null
+++ b/tests/benchmarks/qnetworkreply/main.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+// This file contains benchmarks for QNetworkReply functions.
+
+#include <QDebug>
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtNetwork/qnetworkreply.h>
+#include <QtNetwork/qnetworkrequest.h>
+#include <QtNetwork/qnetworkaccessmanager.h>
+#include "../../auto/network-settings.h"
+
+class tst_qnetworkreply : public QObject
+{
+ Q_OBJECT
+private slots:
+ void httpLatency();
+
+};
+
+void tst_qnetworkreply::httpLatency()
+{
+ QNetworkAccessManager manager;
+ QBENCHMARK{
+ QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/"));
+ QNetworkReply* reply = manager.get(request);
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
+ QTestEventLoop::instance().enterLoop(5);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ delete reply;
+ }
+}
+
+QTEST_MAIN(tst_qnetworkreply)
+
+#include "main.moc"
diff --git a/tests/benchmarks/qnetworkreply/qnetworkreply.pro b/tests/benchmarks/qnetworkreply/qnetworkreply.pro
new file mode 100644
index 0000000..060acf5
--- /dev/null
+++ b/tests/benchmarks/qnetworkreply/qnetworkreply.pro
@@ -0,0 +1,13 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qnetworkreply
+DEPENDPATH += .
+INCLUDEPATH += .
+
+QT -= gui
+QT += network
+
+CONFIG += release
+
+# Input
+SOURCES += main.cpp
diff --git a/tests/benchmarks/qquaternion/qquaternion.pro b/tests/benchmarks/qquaternion/qquaternion.pro
new file mode 100644
index 0000000..cd68423
--- /dev/null
+++ b/tests/benchmarks/qquaternion/qquaternion.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qquaternion
+
+SOURCES += tst_qquaternion.cpp
+
diff --git a/tests/benchmarks/qquaternion/tst_qquaternion.cpp b/tests/benchmarks/qquaternion/tst_qquaternion.cpp
new file mode 100644
index 0000000..eaacf74
--- /dev/null
+++ b/tests/benchmarks/qquaternion/tst_qquaternion.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQuaternion>
+
+//TESTED_FILES=
+
+class tst_QQuaternion : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QQuaternion();
+ virtual ~tst_QQuaternion();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void multiply_data();
+ void multiply();
+};
+
+tst_QQuaternion::tst_QQuaternion()
+{
+}
+
+tst_QQuaternion::~tst_QQuaternion()
+{
+}
+
+void tst_QQuaternion::init()
+{
+}
+
+void tst_QQuaternion::cleanup()
+{
+}
+
+void tst_QQuaternion::multiply_data()
+{
+ QTest::addColumn<qreal>("x1");
+ QTest::addColumn<qreal>("y1");
+ QTest::addColumn<qreal>("z1");
+ QTest::addColumn<qreal>("w1");
+ QTest::addColumn<qreal>("x2");
+ QTest::addColumn<qreal>("y2");
+ QTest::addColumn<qreal>("z2");
+ QTest::addColumn<qreal>("w2");
+
+ QTest::newRow("null")
+ << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f
+ << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f;
+
+ QTest::newRow("unitvec")
+ << (qreal)1.0f << (qreal)0.0f << (qreal)0.0f << (qreal)1.0f
+ << (qreal)0.0f << (qreal)1.0f << (qreal)0.0f << (qreal)1.0f;
+
+ QTest::newRow("complex")
+ << (qreal)1.0f << (qreal)2.0f << (qreal)3.0f << (qreal)7.0f
+ << (qreal)4.0f << (qreal)5.0f << (qreal)6.0f << (qreal)8.0f;
+}
+
+void tst_QQuaternion::multiply()
+{
+ QFETCH(qreal, x1);
+ QFETCH(qreal, y1);
+ QFETCH(qreal, z1);
+ QFETCH(qreal, w1);
+ QFETCH(qreal, x2);
+ QFETCH(qreal, y2);
+ QFETCH(qreal, z2);
+ QFETCH(qreal, w2);
+
+ QQuaternion q1(w1, x1, y1, z1);
+ QQuaternion q2(w2, x2, y2, z2);
+
+ QBENCHMARK {
+ QQuaternion q3 = q1 * q2;
+ }
+}
+
+QTEST_MAIN(tst_QQuaternion)
+#include "tst_qquaternion.moc"
diff --git a/tests/benchmarks/qstring/main.cpp b/tests/benchmarks/qstring/main.cpp
index 2c218df..b53b284 100644
--- a/tests/benchmarks/qstring/main.cpp
+++ b/tests/benchmarks/qstring/main.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include <QStringList>
+#include <QFile>
#include <qtest.h>
class tst_QString: public QObject
@@ -47,6 +48,7 @@ class tst_QString: public QObject
private slots:
void equals() const;
void equals_data() const;
+ void fromUtf8() const;
};
void tst_QString::equals() const
@@ -118,6 +120,22 @@ void tst_QString::equals_data() const
<< QString::fromRawData(ptr + 1, 58) << QString::fromRawData(ptr + 3, 58);
}
+void tst_QString::fromUtf8() const
+{
+ QFile file(SRCDIR "utf-8.txt");
+ if (!file.open(QFile::ReadOnly)) {
+ qFatal("Cannot open input file");
+ return;
+ }
+ QByteArray data = file.readAll();
+ const char *d = data.constData();
+ int size = data.size();
+
+ QBENCHMARK {
+ QString::fromUtf8(d, size);
+ }
+}
+
QTEST_MAIN(tst_QString)
#include "main.moc"
diff --git a/tests/benchmarks/qstring/qstring.pro b/tests/benchmarks/qstring/qstring.pro
index 74423e7..6aad1c0 100644
--- a/tests/benchmarks/qstring/qstring.pro
+++ b/tests/benchmarks/qstring/qstring.pro
@@ -2,3 +2,11 @@ load(qttest_p4)
TARGET = tst_qstring
QT -= gui
SOURCES += main.cpp
+
+wince*:{
+ DEFINES += SRCDIR=\\\"\\\"
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD/\\\"
+}
+
+
diff --git a/tests/benchmarks/qstring/utf-8.txt b/tests/benchmarks/qstring/utf-8.txt
new file mode 100644
index 0000000..a8a58de
--- /dev/null
+++ b/tests/benchmarks/qstring/utf-8.txt
@@ -0,0 +1,72 @@
+Språk: Norsk
+Γλώσσα: Ελληνικά
+Язык: Русский
+언어 : 한국어
+言語: 日本語
+Langage : Français
+Språk: Norsk
+Γλώσσα: Ελληνικά
+Язык: Русский
+언어 : 한국어
+言語: 日本語
+Langage : Français
+Språk: Norsk
+Γλώσσα: Ελληνικά
+Язык: Русский
+언어 : 한국어
+言語: 日本語
+Langage : Français
+Språk: Norsk
+Γλώσσα: Ελληνικά
+Язык: Русский
+언어 : 한국어
+言語: 日本語
+Langage : Français
+Språk: Norsk
+Γλώσσα: Ελληνικά
+Язык: Русский
+언어 : 한국어
+言語: 日本語
+Langage : Français
+Språk: Norsk
+Γλώσσα: Ελληνικά
+Язык: Русский
+언어 : 한국어
+言語: 日本語
+Langage : Français
+Språk: Norsk
+Γλώσσα: Ελληνικά
+Язык: Русский
+언어 : 한국어
+言語: 日本語
+Langage : Français
+Språk: Norsk
+Γλώσσα: Ελληνικά
+Язык: Русский
+언어 : 한국어
+言語: 日本語
+Langage : Français
+Språk: Norsk
+Γλώσσα: Ελληνικά
+Язык: Русский
+언어 : 한국어
+言語: 日本語
+Langage : Français
+Språk: Norsk
+Γλώσσα: Ελληνικά
+Язык: Русский
+언어 : 한국어
+言語: 日本語
+Langage : Français
+Språk: Norsk
+Γλώσσα: Ελληνικά
+Язык: Русский
+언어 : 한국어
+言語: 日本語
+Langage : Français
+Språk: Norsk
+Γλώσσα: Ελληνικά
+Язык: Русский
+언어 : 한국어
+言語: 日本語
+Langage : Français