Panda3D

cacheStats.I

00001 // Filename: cacheStats.I
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 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: CacheStats::maybe_report
00018 //       Access: Public
00019 //  Description: Outputs a report if enough time has elapsed.
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE void CacheStats::
00022 maybe_report(const char *name) {
00023 #ifndef NDEBUG
00024   if (_cache_report) {
00025     double now = ClockObject::get_global_clock()->get_real_time();
00026     if (now - _last_reset < _cache_report_interval) {
00027       return;
00028     }
00029     write(Notify::out(), name);
00030     reset(now);
00031   }
00032 #endif  // NDEBUG
00033 }
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //     Function: CacheStats::inc_hits
00037 //       Access: Public
00038 //  Description: Increments by 1 the count of cache hits.
00039 ////////////////////////////////////////////////////////////////////
00040 INLINE void CacheStats::
00041 inc_hits() {
00042 #ifndef NDEBUG
00043   ++_cache_hits;
00044 #endif // NDEBUG
00045 }
00046 
00047 ////////////////////////////////////////////////////////////////////
00048 //     Function: CacheStats::inc_misses
00049 //       Access: Public
00050 //  Description: Increments by 1 the count of cache misses.
00051 ////////////////////////////////////////////////////////////////////
00052 INLINE void CacheStats::
00053 inc_misses() {
00054 #ifndef NDEBUG
00055   ++_cache_misses;
00056 #endif // NDEBUG
00057 }
00058 
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: CacheStats::inc_adds
00061 //       Access: Public
00062 //  Description: Increments by 1 the count of elements added to the
00063 //               cache.  If is_new is true, the element was added to a
00064 //               previously empty hashtable.
00065 ////////////////////////////////////////////////////////////////////
00066 INLINE void CacheStats::
00067 inc_adds(bool is_new) {
00068 #ifndef NDEBUG
00069   if (is_new) {
00070     ++_cache_new_adds;
00071   }
00072   ++_cache_adds;
00073 #endif // NDEBUG
00074 }
00075 
00076 ////////////////////////////////////////////////////////////////////
00077 //     Function: CacheStats::inc_dels
00078 //       Access: Public
00079 //  Description: Increments by 1 the count of elements removed from
00080 //               the cache.
00081 ////////////////////////////////////////////////////////////////////
00082 INLINE void CacheStats::
00083 inc_dels() {
00084 #ifndef NDEBUG
00085   ++_cache_dels;
00086 #endif // NDEBUG
00087 }
00088 
00089 ////////////////////////////////////////////////////////////////////
00090 //     Function: CacheStats::add_total_size
00091 //       Access: Public
00092 //  Description: Adds the indicated count (positive or negative) to
00093 //               the total number of entries for the cache
00094 //               (net occupied size of all the hashtables).
00095 ////////////////////////////////////////////////////////////////////
00096 INLINE void CacheStats::
00097 add_total_size(int count) {
00098 #ifndef NDEBUG
00099   _total_cache_size += count;
00100 #endif  // NDEBUG
00101 }
00102 
00103 ////////////////////////////////////////////////////////////////////
00104 //     Function: CacheStats::add_num_states
00105 //       Access: Public
00106 //  Description: Adds the indicated count (positive or negative) to
00107 //               the total count of individual RenderState or
00108 //               TransformState objects.
00109 ////////////////////////////////////////////////////////////////////
00110 INLINE void CacheStats::
00111 add_num_states(int count) {
00112 #ifndef NDEBUG
00113   _num_states += count;
00114 #endif  // NDEBUG
00115 }
 All Classes Functions Variables Enumerations