Panda3D
 All Classes Functions Variables Enumerations
cacheStats.I
1 // Filename: cacheStats.I
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 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: CacheStats::maybe_report
18 // Access: Public
19 // Description: Outputs a report if enough time has elapsed.
20 ////////////////////////////////////////////////////////////////////
21 INLINE void CacheStats::
22 maybe_report(const char *name) {
23 #ifndef NDEBUG
24  if (_cache_report) {
26  if (now - _last_reset < _cache_report_interval) {
27  return;
28  }
29  write(Notify::out(), name);
30  reset(now);
31  }
32 #endif // NDEBUG
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function: CacheStats::inc_hits
37 // Access: Public
38 // Description: Increments by 1 the count of cache hits.
39 ////////////////////////////////////////////////////////////////////
40 INLINE void CacheStats::
42 #ifndef NDEBUG
43  ++_cache_hits;
44 #endif // NDEBUG
45 }
46 
47 ////////////////////////////////////////////////////////////////////
48 // Function: CacheStats::inc_misses
49 // Access: Public
50 // Description: Increments by 1 the count of cache misses.
51 ////////////////////////////////////////////////////////////////////
52 INLINE void CacheStats::
54 #ifndef NDEBUG
55  ++_cache_misses;
56 #endif // NDEBUG
57 }
58 
59 ////////////////////////////////////////////////////////////////////
60 // Function: CacheStats::inc_adds
61 // Access: Public
62 // Description: Increments by 1 the count of elements added to the
63 // cache. If is_new is true, the element was added to a
64 // previously empty hashtable.
65 ////////////////////////////////////////////////////////////////////
66 INLINE void CacheStats::
67 inc_adds(bool is_new) {
68 #ifndef NDEBUG
69  if (is_new) {
70  ++_cache_new_adds;
71  }
72  ++_cache_adds;
73 #endif // NDEBUG
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: CacheStats::inc_dels
78 // Access: Public
79 // Description: Increments by 1 the count of elements removed from
80 // the cache.
81 ////////////////////////////////////////////////////////////////////
82 INLINE void CacheStats::
84 #ifndef NDEBUG
85  ++_cache_dels;
86 #endif // NDEBUG
87 }
88 
89 ////////////////////////////////////////////////////////////////////
90 // Function: CacheStats::add_total_size
91 // Access: Public
92 // Description: Adds the indicated count (positive or negative) to
93 // the total number of entries for the cache
94 // (net occupied size of all the hashtables).
95 ////////////////////////////////////////////////////////////////////
96 INLINE void CacheStats::
97 add_total_size(int count) {
98 #ifndef NDEBUG
99  _total_cache_size += count;
100 #endif // NDEBUG
101 }
102 
103 ////////////////////////////////////////////////////////////////////
104 // Function: CacheStats::add_num_states
105 // Access: Public
106 // Description: Adds the indicated count (positive or negative) to
107 // the total count of individual RenderState or
108 // TransformState objects.
109 ////////////////////////////////////////////////////////////////////
110 INLINE void CacheStats::
111 add_num_states(int count) {
112 #ifndef NDEBUG
113  _num_states += count;
114 #endif // NDEBUG
115 }
static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
Definition: clockObject.I:271
void inc_dels()
Increments by 1 the count of elements removed from the cache.
Definition: cacheStats.I:83
static ostream & out()
A convenient way to get the ostream that should be written to for a Notify-type message.
Definition: notify.cxx:301
void reset(double now)
Reinitializes just those parts of the CacheStats that should be reset between each reporting interval...
Definition: cacheStats.cxx:43
void maybe_report(const char *name)
Outputs a report if enough time has elapsed.
Definition: cacheStats.I:22
void inc_hits()
Increments by 1 the count of cache hits.
Definition: cacheStats.I:41
void inc_misses()
Increments by 1 the count of cache misses.
Definition: cacheStats.I:53
void add_total_size(int count)
Adds the indicated count (positive or negative) to the total number of entries for the cache (net occ...
Definition: cacheStats.I:97
void add_num_states(int count)
Adds the indicated count (positive or negative) to the total count of individual RenderState or Trans...
Definition: cacheStats.I:111
double get_real_time() const
Returns the actual number of seconds elapsed since the ClockObject was created, or since it was last ...
Definition: clockObject.I:68
void inc_adds(bool is_new)
Increments by 1 the count of elements added to the cache.
Definition: cacheStats.I:67