From a4680d6051d4c4553a927e7b140451d0243b7332 Mon Sep 17 00:00:00 2001 From: Pavel Vaynerman Date: Fri, 9 Jul 2021 00:56:33 +0300 Subject: [PATCH] [unet-protobuf]: added perf-test --- extensions/UNetUDP/UDPPacket.h | 4 +-- extensions/UNetUDP/tests/test_unet_proto.cc | 33 +++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/extensions/UNetUDP/UDPPacket.h b/extensions/UNetUDP/UDPPacket.h index 18b923234..45fc222c2 100644 --- a/extensions/UNetUDP/UDPPacket.h +++ b/extensions/UNetUDP/UDPPacket.h @@ -34,8 +34,8 @@ namespace uniset // Теоретический размер данных в UDP пакете (исключая заголовки) 65507 // Желательно не вылезать за размер MTU (обычно 1500) - заголовки = 1432 байта // т.е. надо чтобы sizeof(UDPPacket) < 1432 - static const size_t MaxACount = 5000; - static const size_t MaxDCount = 5000; + static const size_t MaxACount = 2000; + static const size_t MaxDCount = 2000; static const size_t MessageBufSize = 34700; struct UDPMessage diff --git a/extensions/UNetUDP/tests/test_unet_proto.cc b/extensions/UNetUDP/tests/test_unet_proto.cc index 5d6847b4a..8f37a1a87 100644 --- a/extensions/UNetUDP/tests/test_unet_proto.cc +++ b/extensions/UNetUDP/tests/test_unet_proto.cc @@ -3,6 +3,7 @@ #include #include "UniSetTypes.h" #include "UDPPacket.h" +#include "PassiveTimer.h" // ----------------------------------------------------------------------------- #include "proto/unet.pb.h" // ----------------------------------------------------------------------------- @@ -113,3 +114,35 @@ TEST_CASE("[UNetUDP]: crc", "[unetudp][protobuf][crc]") REQUIRE( pack.dataCRC() != crc ); REQUIRE( pack.dataCRCWithBuf(buf, sizeof(buf)) != crc_b ); } + +// ----------------------------------------------------------------------------- +TEST_CASE("[UNetUDP]: perf test", "[unetudp][protobuf][perf]") +{ + uint8_t buf[uniset::UniSetUDP::MessageBufSize]; + + UniSetUDP::UDPMessage pack; + REQUIRE(pack.isOk()); + pack.setNodeID(100); + pack.setProcID(100); + pack.setNum(1); + + for( size_t i=0; i