MCPcopy Create free account
hub / github.com/catboost/catboost / SessionLevelTest

Function SessionLevelTest

library/cpp/netliba/v12/udp_test.cpp:79–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77 //}
78
79 static void SessionLevelTest(bool client, const char* serverName, int packetSize, int packetsInFly, int srcPort) {
80 BindToSocket(0);
81 TIntrusivePtr<IRequester> reqHost;
82 // reqHost = CreateHttpUdpRequester(13013);
83 const int port = client ? srcPort : 13013;
84 reqHost = CreateHttpUdpRequester(port);
85 if (!reqHost) {
86 fprintf(stderr, "netliba failed to create http udp requester on port %d\n", port);
87 exit(EXIT_FAILURE);
88 }
89
90 TUdpAddress serverAddr = CreateAddress(serverName, 13013);
91 TVector<char> dummyPacket;
92 dummyPacket.resize(packetSize);
93 TReallyFastRng32 rr(RandomNumber<ui64>());
94 for (size_t i = 0; i < dummyPacket.size(); ++i)
95 dummyPacket[i] = (char)rr.Uniform(256);
96 bool cont = true;
97 NHPTimer::STime t;
98 NHPTimer::GetTime(&t);
99 THashMap<TGUID, bool, TGUIDHash> seenReqs;
100 if (client) {
101 THashMap<TGUID, bool, TGUIDHash> reqList;
102 int packetsSentCount = 0;
103 TUdpHttpRequest* req;
104 for (int i = 1; cont; ++i) {
105 for (;;) {
106 req = reqHost->GetRequest();
107 if (req == nullptr)
108 break;
109 req->Data.resize(10);
110 reqHost->SendResponse(req->ReqId, &req->Data, req->Colors);
111 delete req;
112 }
113 while (TUdpHttpResponse* res = reqHost->GetResponse()) {
114 THashMap<TGUID, bool, TGUIDHash>::iterator z = reqList.find(res->ReqId);
115 if (z == reqList.end()) {
116 printf("Unexpected response\n");
117 abort();
118 }
119 reqList.erase(z);
120 if (res->Ok) {
121 ++packetsSentCount;
122 //Y_ASSERT(res->Data == dummyPacket);
123 NHPTimer::STime tChk = t;
124 if (NHPTimer::GetTimePassed(&tChk) > 1) {
125 printf("packet size = %d\n", dummyPacket.ysize());
126 double passedTime = NHPTimer::GetTimePassed(&t);
127 double rate = packetsSentCount / passedTime;
128 printf("packet rate %g, transfer %gmb\n", rate, rate * dummyPacket.size() / 1000000);
129 packetsSentCount = 0;
130 }
131 } else {
132 printf("Failed request!\n");
133 //Sleep(INFINITE);
134 }
135 delete res;
136 }

Callers 1

RunUdpTestFunction · 0.70

Calls 15

exitFunction · 0.85
TConnectionAddressClass · 0.85
GetGuidAsStringFunction · 0.85
BindToSocketFunction · 0.70
CreateHttpUdpRequesterFunction · 0.70
CreateAddressFunction · 0.70
resizeMethod · 0.45
sizeMethod · 0.45
UniformMethod · 0.45
GetRequestMethod · 0.45
SendResponseMethod · 0.45
GetResponseMethod · 0.45

Tested by

no test coverage detected