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

Function SessionLevelTest

library/cpp/netliba/v6/udp_test.cpp:78–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

RunUdpTestFunction · 0.70

Calls 15

GetCycleCountFunction · 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
findMethod · 0.45

Tested by

no test coverage detected