summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-01-08 10:53:28 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-01-08 10:53:28 (GMT)
commit2e62227f950aac8205f2b67e4d7d046836b2c799 (patch)
tree87e91115d86896949f69e8c8d993ba795422ef3b /tests/benchmarks
parent9b0502aa6abf6bb9c07f205bccdf2d9c65027bde (diff)
parent118e7a807d0764dee97612589fe5d7072d271e1e (diff)
downloadQt-2e62227f950aac8205f2b67e4d7d046836b2c799.zip
Qt-2e62227f950aac8205f2b67e4d7d046836b2c799.tar.gz
Qt-2e62227f950aac8205f2b67e4d7d046836b2c799.tar.bz2
Merge branch '4.6'
Conflicts: src/corelib/io/qfsfileengine.cpp src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp src/opengl/opengl.pro
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/benchmarks.pro1
-rw-r--r--tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp17
-rw-r--r--tests/benchmarks/qhostinfo/main.cpp28
-rw-r--r--tests/benchmarks/qtcpserver/qtcpserver.pro13
-rw-r--r--tests/benchmarks/qtcpserver/tst_qtcpserver.cpp277
5 files changed, 323 insertions, 13 deletions
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro
index 0f760a1..7bb4bb1 100644
--- a/tests/benchmarks/benchmarks.pro
+++ b/tests/benchmarks/benchmarks.pro
@@ -37,6 +37,7 @@ SUBDIRS = containers-associative \
qstringbuilder \
qstylesheetstyle \
qsvgrenderer \
+ qtcpserver \
qtableview \
qthreadstorage
diff --git a/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp
index 1944219..53fd9b6 100644
--- a/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -64,6 +64,7 @@ private slots:
void addItem();
void itemAt_data();
void itemAt();
+ void initialShow();
};
tst_QGraphicsScene::tst_QGraphicsScene()
@@ -227,5 +228,21 @@ void tst_QGraphicsScene::itemAt()
qApp->processEvents();
}
+void tst_QGraphicsScene::initialShow()
+{
+ QGraphicsScene scene;
+
+ QBENCHMARK {
+ for (int y = 0; y < 30000; ++y) {
+ QGraphicsRectItem *item = new QGraphicsRectItem(0, 0, 50, 50);
+ item->setPos((y/2) * item->rect().width(), (y/2) * item->rect().height());
+ scene.addItem(item);
+ }
+ scene.itemAt(0, 0); // triggers indexing
+ //This call polish the items so we bench their processing too.
+ qApp->processEvents();
+ }
+}
+
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"
diff --git a/tests/benchmarks/qhostinfo/main.cpp b/tests/benchmarks/qhostinfo/main.cpp
index 389443b..80d0fd8 100644
--- a/tests/benchmarks/qhostinfo/main.cpp
+++ b/tests/benchmarks/qhostinfo/main.cpp
@@ -7,11 +7,11 @@
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
-** Commercial Usage
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
+** 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 Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -25,19 +25,21 @@
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, 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 have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
+
+
#include <QDebug>
#include <QHostInfo>
#include <QStringList>
diff --git a/tests/benchmarks/qtcpserver/qtcpserver.pro b/tests/benchmarks/qtcpserver/qtcpserver.pro
new file mode 100644
index 0000000..e7bf13a
--- /dev/null
+++ b/tests/benchmarks/qtcpserver/qtcpserver.pro
@@ -0,0 +1,13 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qtcpserver
+DEPENDPATH += .
+INCLUDEPATH += .
+
+QT -= gui
+QT += network
+
+CONFIG += release
+
+# Input
+SOURCES += tst_qtcpserver.cpp
diff --git a/tests/benchmarks/qtcpserver/tst_qtcpserver.cpp b/tests/benchmarks/qtcpserver/tst_qtcpserver.cpp
new file mode 100644
index 0000000..07640b8
--- /dev/null
+++ b/tests/benchmarks/qtcpserver/tst_qtcpserver.cpp
@@ -0,0 +1,277 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// Just to get Q_OS_SYMBIAN
+#include <qglobal.h>
+
+#include <QtTest/QtTest>
+
+
+#include <qcoreapplication.h>
+#include <qtcpsocket.h>
+#include <qtcpserver.h>
+#include <qhostaddress.h>
+#include <qprocess.h>
+#include <qstringlist.h>
+#include <qplatformdefs.h>
+#include <qhostinfo.h>
+
+#include <QNetworkProxy>
+Q_DECLARE_METATYPE(QNetworkProxy)
+Q_DECLARE_METATYPE(QList<QNetworkProxy>)
+
+#include "../../auto/network-settings.h"
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QTcpServer : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QTcpServer();
+ virtual ~tst_QTcpServer();
+
+
+public slots:
+ void initTestCase_data();
+ void init();
+ void cleanup();
+private slots:
+ void ipv4LoopbackPerformanceTest();
+ void ipv6LoopbackPerformanceTest();
+ void ipv4PerformanceTest();
+};
+
+tst_QTcpServer::tst_QTcpServer()
+{
+ Q_SET_DEFAULT_IAP
+}
+
+tst_QTcpServer::~tst_QTcpServer()
+{
+}
+
+void tst_QTcpServer::initTestCase_data()
+{
+ QTest::addColumn<bool>("setProxy");
+ QTest::addColumn<int>("proxyType");
+
+ QTest::newRow("WithoutProxy") << false << 0;
+ QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy);
+}
+
+void tst_QTcpServer::init()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy) {
+ QFETCH_GLOBAL(int, proxyType);
+ if (proxyType == QNetworkProxy::Socks5Proxy) {
+ QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
+ }
+ }
+}
+
+void tst_QTcpServer::cleanup()
+{
+ QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy);
+}
+
+//----------------------------------------------------------------------------------
+void tst_QTcpServer::ipv4LoopbackPerformanceTest()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ QTcpServer server;
+ QVERIFY(server.listen(QHostAddress::LocalHost));
+
+ QVERIFY(server.isListening());
+
+ QTcpSocket clientA;
+ clientA.connectToHost(QHostAddress::LocalHost, server.serverPort());
+ QVERIFY(clientA.waitForConnected(5000));
+ QVERIFY(clientA.state() == QAbstractSocket::ConnectedState);
+
+ QVERIFY(server.waitForNewConnection());
+ QTcpSocket *clientB = server.nextPendingConnection();
+ QVERIFY(clientB);
+
+ QByteArray buffer(16384, '@');
+ QTime stopWatch;
+ stopWatch.start();
+ qlonglong totalWritten = 0;
+ while (stopWatch.elapsed() < 5000) {
+ QVERIFY(clientA.write(buffer.data(), buffer.size()) > 0);
+ clientA.flush();
+ totalWritten += buffer.size();
+ while (clientB->waitForReadyRead(100)) {
+ if (clientB->bytesAvailable() == 16384)
+ break;
+ }
+ clientB->read(buffer.data(), buffer.size());
+ clientB->write(buffer.data(), buffer.size());
+ clientB->flush();
+ totalWritten += buffer.size();
+ while (clientA.waitForReadyRead(100)) {
+ if (clientA.bytesAvailable() == 16384)
+ break;
+ }
+ clientA.read(buffer.data(), buffer.size());
+ }
+
+ qDebug("\t\t%s: %.1fMB/%.1fs: %.1fMB/s",
+ server.serverAddress().toString().toLatin1().constData(),
+ totalWritten / (1024.0 * 1024.0),
+ stopWatch.elapsed() / 1000.0,
+ (totalWritten / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024));
+
+ delete clientB;
+}
+
+//----------------------------------------------------------------------------------
+void tst_QTcpServer::ipv6LoopbackPerformanceTest()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+#if defined(Q_OS_SYMBIAN)
+ QSKIP("Symbian: IPv6 is not yet supported", SkipAll);
+#endif
+ QTcpServer server;
+ if (!server.listen(QHostAddress::LocalHostIPv6, 0)) {
+ QVERIFY(server.serverError() == QAbstractSocket::UnsupportedSocketOperationError);
+ } else {
+ QTcpSocket clientA;
+ clientA.connectToHost(server.serverAddress(), server.serverPort());
+ QVERIFY(clientA.waitForConnected(5000));
+
+ QVERIFY(server.waitForNewConnection(5000));
+ QTcpSocket *clientB = server.nextPendingConnection();
+ QVERIFY(clientB);
+
+ QByteArray buffer(16384, '@');
+ QTime stopWatch;
+ stopWatch.start();
+ qlonglong totalWritten = 0;
+ while (stopWatch.elapsed() < 5000) {
+ clientA.write(buffer.data(), buffer.size());
+ clientA.flush();
+ totalWritten += buffer.size();
+ while (clientB->waitForReadyRead(100)) {
+ if (clientB->bytesAvailable() == 16384)
+ break;
+ }
+ clientB->read(buffer.data(), buffer.size());
+ clientB->write(buffer.data(), buffer.size());
+ clientB->flush();
+ totalWritten += buffer.size();
+ while (clientA.waitForReadyRead(100)) {
+ if (clientA.bytesAvailable() == 16384)
+ break;
+ }
+ clientA.read(buffer.data(), buffer.size());
+ }
+
+ qDebug("\t\t%s: %.1fMB/%.1fs: %.1fMB/s",
+ server.serverAddress().toString().toLatin1().constData(),
+ totalWritten / (1024.0 * 1024.0),
+ stopWatch.elapsed() / 1000.0,
+ (totalWritten / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024));
+ delete clientB;
+ }
+}
+
+//----------------------------------------------------------------------------------
+void tst_QTcpServer::ipv4PerformanceTest()
+{
+ QTcpSocket probeSocket;
+ probeSocket.connectToHost(QtNetworkSettings::serverName(), 143);
+ QVERIFY(probeSocket.waitForConnected(5000));
+
+ QTcpServer server;
+ QVERIFY(server.listen(probeSocket.localAddress(), 0));
+
+ QTcpSocket clientA;
+ clientA.connectToHost(server.serverAddress(), server.serverPort());
+ QVERIFY(clientA.waitForConnected(5000));
+
+ QVERIFY(server.waitForNewConnection(5000));
+ QTcpSocket *clientB = server.nextPendingConnection();
+ QVERIFY(clientB);
+
+ QByteArray buffer(16384, '@');
+ QTime stopWatch;
+ stopWatch.start();
+ qlonglong totalWritten = 0;
+ while (stopWatch.elapsed() < 5000) {
+ qlonglong writtenA = clientA.write(buffer.data(), buffer.size());
+ clientA.flush();
+ totalWritten += buffer.size();
+ while (clientB->waitForReadyRead(100)) {
+ if (clientB->bytesAvailable() == writtenA)
+ break;
+ }
+ clientB->read(buffer.data(), buffer.size());
+ qlonglong writtenB = clientB->write(buffer.data(), buffer.size());
+ clientB->flush();
+ totalWritten += buffer.size();
+ while (clientA.waitForReadyRead(100)) {
+ if (clientA.bytesAvailable() == writtenB)
+ break;
+ }
+ clientA.read(buffer.data(), buffer.size());
+ }
+
+ qDebug("\t\t%s: %.1fMB/%.1fs: %.1fMB/s",
+ probeSocket.localAddress().toString().toLatin1().constData(),
+ totalWritten / (1024.0 * 1024.0),
+ stopWatch.elapsed() / 1000.0,
+ (totalWritten / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024));
+
+ delete clientB;
+}
+
+QTEST_MAIN(tst_QTcpServer)
+#include "tst_qtcpserver.moc"