forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcacheStats.I
More file actions
115 lines (107 loc) · 3.6 KB
/
cacheStats.I
File metadata and controls
115 lines (107 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Filename: cacheStats.I
// Created by: drose (24Jul07)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: CacheStats::maybe_report
// Access: Public
// Description: Outputs a report if enough time has elapsed.
////////////////////////////////////////////////////////////////////
INLINE void CacheStats::
maybe_report(const char *name) {
#ifndef NDEBUG
if (_cache_report) {
double now = ClockObject::get_global_clock()->get_real_time();
if (now - _last_reset < _cache_report_interval) {
return;
}
write(Notify::out(), name);
reset(now);
}
#endif // NDEBUG
}
////////////////////////////////////////////////////////////////////
// Function: CacheStats::inc_hits
// Access: Public
// Description: Increments by 1 the count of cache hits.
////////////////////////////////////////////////////////////////////
INLINE void CacheStats::
inc_hits() {
#ifndef NDEBUG
++_cache_hits;
#endif // NDEBUG
}
////////////////////////////////////////////////////////////////////
// Function: CacheStats::inc_misses
// Access: Public
// Description: Increments by 1 the count of cache misses.
////////////////////////////////////////////////////////////////////
INLINE void CacheStats::
inc_misses() {
#ifndef NDEBUG
++_cache_misses;
#endif // NDEBUG
}
////////////////////////////////////////////////////////////////////
// Function: CacheStats::inc_adds
// Access: Public
// Description: Increments by 1 the count of elements added to the
// cache. If is_new is true, the element was added to a
// previously empty hashtable.
////////////////////////////////////////////////////////////////////
INLINE void CacheStats::
inc_adds(bool is_new) {
#ifndef NDEBUG
if (is_new) {
++_cache_new_adds;
}
++_cache_adds;
#endif // NDEBUG
}
////////////////////////////////////////////////////////////////////
// Function: CacheStats::inc_dels
// Access: Public
// Description: Increments by 1 the count of elements removed from
// the cache.
////////////////////////////////////////////////////////////////////
INLINE void CacheStats::
inc_dels() {
#ifndef NDEBUG
++_cache_dels;
#endif // NDEBUG
}
////////////////////////////////////////////////////////////////////
// Function: CacheStats::add_total_size
// Access: Public
// Description: Adds the indicated count (positive or negative) to
// the total number of entries for the cache
// (net occupied size of all the hashtables).
////////////////////////////////////////////////////////////////////
INLINE void CacheStats::
add_total_size(int count) {
#ifndef NDEBUG
_total_cache_size += count;
#endif // NDEBUG
}
////////////////////////////////////////////////////////////////////
// Function: CacheStats::add_num_states
// Access: Public
// Description: Adds the indicated count (positive or negative) to
// the total count of individual RenderState or
// TransformState objects.
////////////////////////////////////////////////////////////////////
INLINE void CacheStats::
add_num_states(int count) {
#ifndef NDEBUG
_num_states += count;
#endif // NDEBUG
}