Panda3D
|
00001 // Filename: cacheStats.h 00002 // Created by: drose (24Jul07) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef CACHESTATS_H 00016 #define CACHESTATS_H 00017 00018 #include "pandabase.h" 00019 #include "clockObject.h" 00020 #include "pnotify.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : CacheStats 00024 // Description : This is used to track the utilization of the 00025 // TransformState and RenderState caches, for low-level 00026 // performance tuning information. 00027 //////////////////////////////////////////////////////////////////// 00028 class EXPCL_PANDA_PGRAPH CacheStats { 00029 public: 00030 void init(); 00031 void reset(double now); 00032 void write(ostream &out, const char *name) const; 00033 INLINE void maybe_report(const char *name); 00034 00035 INLINE void inc_hits(); 00036 INLINE void inc_misses(); 00037 INLINE void inc_adds(bool is_new); 00038 INLINE void inc_dels(); 00039 INLINE void add_total_size(int count); 00040 INLINE void add_num_states(int count); 00041 00042 private: 00043 #ifndef NDEBUG 00044 int _cache_hits; 00045 int _cache_misses; 00046 int _cache_adds; 00047 int _cache_new_adds; 00048 int _cache_dels; 00049 int _total_cache_size; 00050 int _num_states; 00051 double _last_reset; 00052 00053 bool _cache_report; 00054 double _cache_report_interval; 00055 #endif // NDEBUG 00056 }; 00057 00058 #include "cacheStats.I" 00059 00060 #endif