|
Odamex
Setting the Standard in Multiplayer Doom
|
00001 // Emacs style mode select -*- C++ -*- 00002 //----------------------------------------------------------------------------- 00003 // 00004 // $Id: stats.h 1788 2010-08-24 04:42:57Z russellrice $ 00005 // 00006 // Copyright (C) 1998-2006 by Randy Heit (ZDoom). 00007 // Copyright (C) 2006-2010 by The Odamex Team. 00008 // 00009 // This program is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU General Public License 00011 // as published by the Free Software Foundation; either version 2 00012 // of the License, or (at your option) any later version. 00013 // 00014 // This program is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // DESCRIPTION: 00020 // STATS 00021 // 00022 //----------------------------------------------------------------------------- 00023 00024 00025 #ifndef __STATS_H__ 00026 #define __STATS_H__ 00027 00028 #include <vector> 00029 #include <string> 00030 #include <algorithm> 00031 00032 class FStat 00033 { 00034 public: 00035 FStat (const char *cname); 00036 00037 virtual ~FStat (); 00038 00039 void clock(); 00040 void unclock(); 00041 void reset(); 00042 00043 const char *getname(); 00044 00045 static void dumpstat(); 00046 static void dumpstat(std::string which); 00047 void dump(); 00048 00049 private: 00050 00051 QWORD last_clock, last_elapsed; 00052 std::string name; 00053 static std::vector<FStat*> stats; 00054 }; 00055 00056 #define BEGIN_STAT(n) \ 00057 static class Stat_##n : public FStat { \ 00058 public: \ 00059 Stat_##n () : FStat (#n) {} \ 00060 } Stat_var_##n; Stat_var_##n.clock(); 00061 00062 #define END_STAT(n) Stat_var_##n.unclock(); 00063 00064 #endif //__STATS_H__ 00065 00066