summaryrefslogtreecommitdiff
path: root/src/debug.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2010-11-27 17:18:34 +0200
committerPerttu Ahola <celeron55@gmail.com>2010-11-27 17:18:34 +0200
commit24c4b7c68d283a4d1de72a3eb68f1268f1fe34e3 (patch)
treec65ee918cc55d7a631aa312a24cc34bb8dea47b4 /src/debug.h
parent4e249fb3fbf75f0359758760d88e22aa5b14533c (diff)
downloadminetest-24c4b7c68d283a4d1de72a3eb68f1268f1fe34e3.tar.gz
minetest-24c4b7c68d283a4d1de72a3eb68f1268f1fe34e3.tar.bz2
minetest-24c4b7c68d283a4d1de72a3eb68f1268f1fe34e3.zip
Working version before block send priorization update
Diffstat (limited to 'src/debug.h')
-rw-r--r--src/debug.h57
1 files changed, 55 insertions, 2 deletions
diff --git a/src/debug.h b/src/debug.h
index 014456c0a..1780025a3 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -3,7 +3,7 @@
*/
/*
- Debug stack and assertion
+ Debug stuff
*/
#ifndef DEBUG_HEADER
@@ -172,5 +172,58 @@ private:
DEBUG_STACK_TEXT_SIZE, __VA_ARGS__);\
DebugStacker __debug_stacker(__buf);
-#endif
+/*
+ Packet counter
+*/
+
+class PacketCounter
+{
+public:
+ PacketCounter()
+ {
+ }
+
+ void add(u16 command)
+ {
+ core::map<u16, u16>::Node *n = m_packets.find(command);
+ if(n == NULL)
+ {
+ m_packets[command] = 1;
+ }
+ else
+ {
+ n->setValue(n->getValue()+1);
+ }
+ }
+
+ void clear()
+ {
+ for(core::map<u16, u16>::Iterator
+ i = m_packets.getIterator();
+ i.atEnd() == false; i++)
+ {
+ i.getNode()->setValue(0);
+ }
+ }
+
+ void print(std::ostream &o)
+ {
+ for(core::map<u16, u16>::Iterator
+ i = m_packets.getIterator();
+ i.atEnd() == false; i++)
+ {
+ o<<"cmd "<<i.getNode()->getKey()
+ <<" count "<<i.getNode()->getValue()
+ <<std::endl;
+ }
+ }
+
+private:
+ // command, count
+ core::map<u16, u16> m_packets;
+};
+
+
+#endif // DEBUG_HEADER
+