Created
March 27, 2015 09:20
-
-
Save jturcotte/d787bf8c0c6f3f92405d to your computer and use it in GitHub Desktop.
Add a multipart put test to see if this can improve performances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 5a7b154e70a14a7ce0df1170d9e8e8e9b8342c8b Mon Sep 17 00:00:00 2001 | |
From: Jocelyn Turcotte <[email protected]> | |
Date: Fri, 27 Mar 2015 10:07:01 +0100 | |
Subject: [PATCH] Add a multipart put test to see if this can improve | |
performances | |
--- | |
performance-tests-c++/main.cpp | 36 ++++++++++++++++++++++++++++++++++++ | |
1 file changed, 36 insertions(+) | |
diff --git a/performance-tests-c++/main.cpp b/performance-tests-c++/main.cpp | |
index 87b970c..c3fa852 100644 | |
--- a/performance-tests-c++/main.cpp | |
+++ b/performance-tests-c++/main.cpp | |
@@ -1,6 +1,7 @@ | |
#include <QAuthenticator> | |
#include <QBuffer> | |
#include <QCoreApplication> | |
+#include <QHttpMultiPart> | |
#include <QNetworkAccessManager> | |
#include <QNetworkReply> | |
#include <QNetworkRequest> | |
@@ -43,6 +44,8 @@ private slots: | |
void cleanupTestCase(); | |
void putFile_data(); | |
void putFile(); | |
+ void putFileMultipart_data(); | |
+ void putFileMultipart(); | |
void getFile_data(); | |
void getFile(); | |
void propfind_data(); | |
@@ -134,6 +137,39 @@ void Test::putFile() | |
} | |
} | |
+void Test::putFileMultipart_data() | |
+{ | |
+ QTest::addColumn<int>("fileSize"); | |
+ QTest::newRow("1k") << 1024; | |
+} | |
+ | |
+void Test::putFileMultipart() | |
+{ | |
+ QFETCH(int, fileSize); | |
+ QByteArray fileContents{fileSize, 'W'}; | |
+ | |
+ QHttpMultiPart mp; | |
+ | |
+ QBENCHMARK { | |
+ QHttpPart p; | |
+ p.setRawHeader("Method", "PUT"); | |
+ p.setRawHeader("URI", testDataUri.path().toLatin1() + "/test" + QTest::currentDataTag() + ".dat"); | |
+ p.setBody(fileContents); | |
+ mp.append(p); | |
+ } | |
+ | |
+ // Consider the batched request time together with the actual iterations. | |
+ QNetworkRequest req{rootUri}; | |
+ QBENCHMARK_ONCE { | |
+ auto r = qnam.put(req, &mp); | |
+ QSignalSpy finishSpy{r, &QNetworkReply::finished}; | |
+ QVERIFY(finishSpy.wait()); | |
+ if (r->error()) | |
+ qWarning() << r->error() << r->errorString(); | |
+ // QCOMPARE((int)r->error(), 0); | |
+ } | |
+} | |
+ | |
void Test::getFile_data() | |
{ | |
QTest::addColumn<int>("fileSize"); | |
-- | |
2.3.3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment