From c388d7b818881a48dbc418863b389f16d44ac6c3 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 11 Aug 2021 17:16:26 +0800 Subject: [PATCH] [TD-5838] add function of speed test --- src/util/src/tnettest.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c index 6519f56121..c946d87ff6 100644 --- a/src/util/src/tnettest.c +++ b/src/util/src/tnettest.c @@ -567,20 +567,6 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, return; } - memset(&epSet, 0, sizeof(SRpcEpSet)); - epSet.inUse = 0; - epSet.numOfEps = 1; - epSet.port[0] = port; - strcpy(epSet.fqdn[0], host); - - reqMsg.msgType = TSDB_MSG_TYPE_NETWORK_TEST; - reqMsg.pCont = rpcMallocCont(pkgLen); - reqMsg.contLen = pkgLen; - reqMsg.code = 0; - reqMsg.handle = NULL; // rpc handle returned to app - reqMsg.ahandle = NULL; // app handle set by client - strcpy(reqMsg.pCont, "nettest speed"); - // record config int32_t compressTmp = tsCompressMsgSize; int32_t maxUdpSize = tsRpcMaxUdpSize; @@ -596,6 +582,21 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, int64_t startT = taosGetTimestampMs(); for (int32_t i = 0; i < pkgNum; i++) { int64_t startTime = taosGetTimestampMs(); + + memset(&epSet, 0, sizeof(SRpcEpSet)); + epSet.inUse = 0; + epSet.numOfEps = 1; + epSet.port[0] = port; + strcpy(epSet.fqdn[0], host); + + reqMsg.msgType = TSDB_MSG_TYPE_NETWORK_TEST; + reqMsg.pCont = rpcMallocCont(pkgLen); + reqMsg.contLen = pkgLen; + reqMsg.code = 0; + reqMsg.handle = NULL; // rpc handle returned to app + reqMsg.ahandle = NULL; // app handle set by client + strcpy(reqMsg.pCont, "nettest speed"); + rpcSendRecv(pRpcConn, &epSet, &reqMsg, &rspMsg); int code = 0; @@ -606,6 +607,8 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, totalSucc ++; } + rpcFreeCont(rspMsg.pCont); + int64_t endTime = taosGetTimestampMs(); int32_t el = endTime - startTime; printf("progress: %5d/%d, status: %d, cost: %10d ms, speed: %10.2lf KB/s\n", i, pkgNum, code, el, pkgLen/(el/1000.0)/1024); @@ -613,7 +616,7 @@ static void taosNetTestSpeed(char *host, int32_t port, int32_t pkgLen, int64_t endT = taosGetTimestampMs(); int32_t elT = endT - startT; printf("total: %5d/%d, cost: %10d ms, speed: %10.2lf KB/s\n", totalSucc, pkgNum, elT, pkgLen * totalSucc/(elT/1000.0)/1024); - rpcFreeCont(rspMsg.pCont); + rpcClose(pRpcConn); // return config -- GitLab