cacheStats.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Filename: cacheStats.h
  2. // Created by: drose (24Jul07)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #ifndef CACHESTATS_H
  15. #define CACHESTATS_H
  16. #include "pandabase.h"
  17. #include "clockObject.h"
  18. #include "pnotify.h"
  19. ////////////////////////////////////////////////////////////////////
  20. // Class : CacheStats
  21. // Description : This is used to track the utilization of the
  22. // TransformState and RenderState caches, for low-level
  23. // performance tuning information.
  24. ////////////////////////////////////////////////////////////////////
  25. class EXPCL_PANDA_PGRAPH CacheStats {
  26. public:
  27. void init();
  28. void reset(double now);
  29. void write(ostream &out, const char *name) const;
  30. INLINE void maybe_report(const char *name);
  31. INLINE void inc_hits();
  32. INLINE void inc_misses();
  33. INLINE void inc_adds(bool is_new);
  34. INLINE void inc_dels();
  35. INLINE void add_total_size(int count);
  36. INLINE void add_num_states(int count);
  37. private:
  38. #ifndef NDEBUG
  39. int _cache_hits;
  40. int _cache_misses;
  41. int _cache_adds;
  42. int _cache_new_adds;
  43. int _cache_dels;
  44. int _total_cache_size;
  45. int _num_states;
  46. double _last_reset;
  47. bool _cache_report;
  48. double _cache_report_interval;
  49. #endif // NDEBUG
  50. };
  51. #include "cacheStats.I"
  52. #endif