This commit is contained in:
aozhiwei 2024-05-29 11:13:40 +08:00
parent d8a2bcbafe
commit 8a86a795cd
3 changed files with 19 additions and 0 deletions

View File

@ -1,5 +1,7 @@
#pragma once
#include <atomic>
#include <a8/singleton.h>
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<long long> server_send_bytes = {0};
std::atomic<long long> server_consume_bytes = {0};
std::atomic<long long> conn_send_bytes = {0};
std::atomic<long long> conn_consume_bytes = {0};
};

View File

@ -13,6 +13,7 @@
#include <a8/a8.h>
#include <a8/tcpclient.h>
#include <a8/perfmonitor.h>
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 {

View File

@ -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;