Panda3D
cacheStats.cxx
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.cxx
10  * @author drose
11  * @date 2007-07-24
12  */
13 
14 #include "cacheStats.h"
15 
16 /**
17  * Initializes the CacheStats for the first time. We don't use the
18  * constructor for this, since we can't guarantee ordering of static
19  * constructors.
20  */
21 void CacheStats::
22 init() {
23 #ifndef NDEBUG
24  // Let's not use the clock at static init time.
25  //reset(ClockObject::get_global_clock()->get_real_time());
26 
27  _cache_report = ConfigVariableBool("cache-report", false);
28  _cache_report_interval = ConfigVariableDouble("cache-report-interval", 5.0);
29 #endif // NDEBUG
30 }
31 
32 /**
33  * Reinitializes just those parts of the CacheStats that should be reset
34  * between each reporting interval.
35  */
36 void CacheStats::
37 reset(double now) {
38 #ifndef NDEBUG
39  _cache_hits = 0;
40  _cache_misses = 0;
41  _cache_adds = 0;
42  _cache_new_adds = 0;
43  _cache_dels = 0;
44  _last_reset = now;
45 #endif // NDEBUG
46 }
47 
48 /**
49  *
50  */
51 void CacheStats::
52 write(std::ostream &out, const char *name) const {
53 #ifndef NDEBUG
54  out << name << " cache: " << _cache_hits << " hits, "
55  << _cache_misses << " misses\n"
56  << _cache_adds + _cache_new_adds << "(" << _cache_new_adds << ") adds(new), "
57  << _cache_dels << " dels, "
58  << _total_cache_size << " / " << _num_states << " = "
59  << (double)_total_cache_size / (double)_num_states
60  << " average cache size\n";
61 #endif // NDEBUG
62 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a convenience class to specialize ConfigVariable as a boolean type.
void reset(double now)
Reinitializes just those parts of the CacheStats that should be reset between each reporting interval...
Definition: cacheStats.cxx:37
This is a convenience class to specialize ConfigVariable as a floating- point type.
void init()
Initializes the CacheStats for the first time.
Definition: cacheStats.cxx:22