diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2010-01-04 14:02:29 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2010-01-04 14:09:34 (GMT) |
commit | bc1ca85d59e680d6b4f5374775a7a7278650c8a9 (patch) | |
tree | 582ec54f41edb8fa41bb997a7bba1558260e5ecc /tests/auto/qtcpserver | |
parent | 5153767a8e4c9b01eef05bf25881eab44a7cd725 (diff) | |
download | Qt-bc1ca85d59e680d6b4f5374775a7a7278650c8a9.zip Qt-bc1ca85d59e680d6b4f5374775a7a7278650c8a9.tar.gz Qt-bc1ca85d59e680d6b4f5374775a7a7278650c8a9.tar.bz2 |
tst_qtcpserver: Move benchmarks
Move benchmarks into tests/benchmarks directory.
Reviewed-by: Thiago
Diffstat (limited to 'tests/auto/qtcpserver')
-rw-r--r-- | tests/auto/qtcpserver/tst_qtcpserver.cpp | 156 |
1 files changed, 0 insertions, 156 deletions
diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp index 8575bd2..4567435 100644 --- a/tests/auto/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp @@ -93,9 +93,6 @@ private slots: void constructing(); void clientServerLoop(); void ipv6Server(); - void ipv4LoopbackPerformanceTest(); - void ipv6LoopbackPerformanceTest(); - void ipv4PerformanceTest(); void crashTests(); void maxPendingConnections(); void listenError(); @@ -248,159 +245,6 @@ void tst_QTcpServer::ipv6Server() } //---------------------------------------------------------------------------------- -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() -{ -#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; -} - -//---------------------------------------------------------------------------------- void tst_QTcpServer::crashTests() { QTcpServer server; |