Add serialization/derserialization benchmark test

This commit is contained in:
Alexander Lohnau 2024-09-08 11:52:40 +02:00 committed by Albert Vaca Cintora
parent e7056baa10
commit 8ef703ddfa

View file

@ -5,6 +5,7 @@
*/
#include "smsapp/smshelper.h"
#include "networkpacket.h"
#include <QtTest>
@ -35,6 +36,25 @@ private Q_SLOTS:
void testDifferentPhoneNumbers2();
void testAllZeros();
void testEmptyInput();
void benchmark_serialize()
{
NetworkPacket pack(QStringLiteral("bla"), QVariantMap{{QStringLiteral("test"), 54321}});
pack.setPayloadTransferInfo({{QStringLiteral("testme"), 123}});
QBENCHMARK {
pack.serialize();
}
}
void benchmark_deserialize()
{
NetworkPacket pack(QStringLiteral("bla"), QVariantMap{{QStringLiteral("test"), 54321}});
pack.setPayloadTransferInfo({{QStringLiteral("testme"), 123}});
auto serialized = pack.serialize();
QBENCHMARK {
NetworkPacket packet;
NetworkPacket::unserialize(serialized, &packet);
}
}
};
/**