1
0

Added temporary debug statistics of the RelEntMoveLook packet removal efficiency

git-svn-id: http://mc-server.googlecode.com/svn/trunk@740 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-08-15 20:37:08 +00:00
parent 16dda8e037
commit 5bc07ba743

View File

@ -1298,11 +1298,14 @@ void cClientHandle::Send(const cPacket & a_Packet, ENUM_PRIORITY a_Priority /* =
}
// Optimize away multiple queued RelativeEntityMoveLook packets:
static int NumRelEntMoveLookTotal = 0;
static int NumRelEntMoveLookRemoved = 0;
cCSLock Lock(m_CSPackets);
if (a_Priority == E_PRIORITY_NORMAL)
{
if (a_Packet.m_PacketID == E_REL_ENT_MOVE_LOOK)
{
NumRelEntMoveLookTotal++;
PacketList & Packets = m_PendingNrmSendPackets;
const cPacket_RelativeEntityMoveLook & ThisPacketData = reinterpret_cast< const cPacket_RelativeEntityMoveLook &>(a_Packet);
for (PacketList::iterator itr = Packets.begin(); itr != Packets.end(); ++itr)
@ -1318,6 +1321,7 @@ void cClientHandle::Send(const cPacket & a_Packet, ENUM_PRIORITY a_Priority /* =
Packets.erase(itr);
bBreak = true;
delete PacketData;
NumRelEntMoveLookRemoved++;
break;
}
break;
@ -1328,6 +1332,14 @@ void cClientHandle::Send(const cPacket & a_Packet, ENUM_PRIORITY a_Priority /* =
break;
}
} // for itr - Packets[]
if ((NumRelEntMoveLookTotal % 1000) == 10) // print out a debug statistics every 1000 packets sent
{
LOGD("RelEntMoveLook optimization: removed %d out of %d packets, saved %d bytes (%d KiB) of bandwidth",
NumRelEntMoveLookRemoved, NumRelEntMoveLookTotal,
NumRelEntMoveLookRemoved * sizeof(cPacket_RelativeEntityMoveLook),
NumRelEntMoveLookRemoved * sizeof(cPacket_RelativeEntityMoveLook) / 1024
);
}
} // if (E_REL_ENT_MOVE_LOOK
m_PendingNrmSendPackets.push_back(a_Packet.Clone());
}