Panda3D
Loading...
Searching...
No Matches
cacheStats.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file cacheStats.I
10 * @author drose
11 * @date 2007-07-24
12 */
13
14/**
15 * Outputs a report if enough time has elapsed.
16 */
17INLINE void CacheStats::
18maybe_report(const char *name) {
19#ifndef NDEBUG
20 if (UNLIKELY(_cache_report)) {
22 if (now - _last_reset < _cache_report_interval) {
23 return;
24 }
25 write(Notify::out(), name);
26 reset(now);
27 }
28#endif // NDEBUG
29}
30
31/**
32 * Increments by 1 the count of cache hits.
33 */
34INLINE void CacheStats::
35inc_hits() {
36#ifndef NDEBUG
37 ++_cache_hits;
38#endif // NDEBUG
39}
40
41/**
42 * Increments by 1 the count of cache misses.
43 */
44INLINE void CacheStats::
45inc_misses() {
46#ifndef NDEBUG
47 ++_cache_misses;
48#endif // NDEBUG
49}
50
51/**
52 * Increments by 1 the count of elements added to the cache. If is_new is
53 * true, the element was added to a previously empty hashtable.
54 */
55INLINE void CacheStats::
56inc_adds(bool is_new) {
57#ifndef NDEBUG
58 if (is_new) {
59 ++_cache_new_adds;
60 }
61 ++_cache_adds;
62#endif // NDEBUG
63}
64
65/**
66 * Increments by 1 the count of elements removed from the cache.
67 */
68INLINE void CacheStats::
69inc_dels() {
70#ifndef NDEBUG
71 ++_cache_dels;
72#endif // NDEBUG
73}
74
75/**
76 * Adds the indicated count (positive or negative) to the total number of
77 * entries for the cache (net occupied size of all the hashtables).
78 */
79INLINE void CacheStats::
80add_total_size(int count) {
81#ifndef NDEBUG
82 _total_cache_size += count;
83#endif // NDEBUG
84}
85
86/**
87 * Adds the indicated count (positive or negative) to the total count of
88 * individual RenderState or TransformState objects.
89 */
90INLINE void CacheStats::
91add_num_states(int count) {
92#ifndef NDEBUG
93 _num_states += count;
94#endif // NDEBUG
95}
void reset(double now)
Reinitializes just those parts of the CacheStats that should be reset between each reporting interval...
void inc_adds(bool is_new)
Increments by 1 the count of elements added to the cache.
Definition cacheStats.I:56
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:80
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:91
void maybe_report(const char *name)
Outputs a report if enough time has elapsed.
Definition cacheStats.I:18
void inc_dels()
Increments by 1 the count of elements removed from the cache.
Definition cacheStats.I:69
void inc_hits()
Increments by 1 the count of cache hits.
Definition cacheStats.I:35
void inc_misses()
Increments by 1 the count of cache misses.
Definition cacheStats.I:45
get_real_time
Returns the actual number of seconds elapsed since the ClockObject was created, or since it was last ...
Definition clockObject.h:92
static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
static std::ostream & out()
A convenient way to get the ostream that should be written to for a Notify- type message.
Definition notify.cxx:265