diff --git a/a8/perfmonitor.h b/a8/perfmonitor.h index 9d2db44..c9576b6 100644 --- a/a8/perfmonitor.h +++ b/a8/perfmonitor.h @@ -1,5 +1,7 @@ #pragma once +#include + #include namespace a8 @@ -20,6 +22,10 @@ namespace a8 long long recv_eagain_times = 0; long long max_send_time = 0; long long max_recv_time = 0; + std::atomic server_send_bytes = {0}; + std::atomic server_consume_bytes = {0}; + std::atomic conn_send_bytes = {0}; + std::atomic conn_consume_bytes = {0}; }; diff --git a/a8/tcpclient.cc b/a8/tcpclient.cc index f91e604..665803c 100644 --- a/a8/tcpclient.cc +++ b/a8/tcpclient.cc @@ -13,6 +13,7 @@ #include #include +#include const int MAX_RECV_BUFFERSIZE = 1024 * 64; @@ -65,6 +66,9 @@ namespace a8 void TcpClient::SendBuff(const char* buff, unsigned int bufflen) { if (bufflen > 0) { +#ifdef A8_PERFT + PerfMonitor::Instance()->conn_send_bytes += bufflen; +#endif a8::SendQueueNode* p = (a8::SendQueueNode*)malloc(sizeof(a8::SendQueueNode)); memset(p, 0, sizeof(SendQueueNode)); p->buff = (char*)malloc(bufflen); @@ -217,6 +221,9 @@ namespace a8 currnode->buff + currnode->sent_bytes, currnode->bufflen - currnode->sent_bytes, 0); +#ifdef A8_PERFT + PerfMonitor::Instance()->conn_send_bytes += len; +#endif if (len > 0) { currnode->sent_bytes += len; } else { diff --git a/a8/tcpsession.cc b/a8/tcpsession.cc index 24fb1fb..009a84b 100644 --- a/a8/tcpsession.cc +++ b/a8/tcpsession.cc @@ -68,6 +68,9 @@ namespace a8 return; } if (bufflen > 0) { +#ifdef A8_PERFT + PerfMonitor::Instance()->conn_send_bytes += bufflen; +#endif a8::SendQueueNode* p = (a8::SendQueueNode*)malloc(sizeof(a8::SendQueueNode)); memset(p, 0, sizeof(a8::SendQueueNode)); p->buff = (char*)malloc(bufflen); @@ -299,6 +302,9 @@ namespace a8 } } work_node_->sent_bytes += sentbytes; +#ifdef A8_PERFT + PerfMonitor::Instance()->server_consume_bytes += sentbytes; +#endif if (work_node_->sent_bytes >= work_node_->bufflen) { a8::SendQueueNode *pdelnode = work_node_; work_node_ = work_node_->next;