Blender  V2.93
stats.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2018 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __RENDER_STATS_H__
18 #define __RENDER_STATS_H__
19 
20 #include "render/scene.h"
21 
22 #include "util/util_stats.h"
23 #include "util/util_string.h"
24 #include "util/util_vector.h"
25 
27 
28 /* Named statistics entry, which corresponds to a size. There is no real
29  * semantic around the units of size, it just should be the same for all
30  * entries.
31  *
32  * This is a generic entry for all size-related statistics, which helps
33  * avoiding duplicating code for things like sorting.
34  */
36  public:
38  NamedSizeEntry(const string &name, size_t size);
39 
40  string name;
41  size_t size;
42 };
43 
45  public:
47  NamedTimeEntry(const string &name, double time);
48 
49  string name;
50  double time;
51 };
52 
53 /* Container of named size entries. Used, for example, to store per-mesh memory
54  * usage statistics. But also keeps track of overall memory usage of the
55  * container.
56  */
58  public:
60 
61  /* Add entry to the statistics. */
62  void add_entry(const NamedSizeEntry &entry);
63 
64  /* Generate full human-readable report. */
65  string full_report(int indent_level = 0);
66 
67  /* Total size of all entries. */
68  size_t total_size;
69 
70  /* NOTE: Is fine to read directly, but for adding use add_entry(), which
71  * makes sure all accumulating values are properly updated.
72  */
74 };
75 
77  public:
79 
80  /* Add entry to the statistics. */
81  void add_entry(const NamedTimeEntry &entry)
82  {
83  total_time += entry.time;
84  entries.push_back(entry);
85  }
86 
87  /* Generate full human-readable report. */
88  string full_report(int indent_level = 0);
89 
90  /* Total time of all entries. */
91  double total_time;
92 
93  /* NOTE: Is fine to read directly, but for adding use add_entry(), which
94  * makes sure all accumulating values are properly updated.
95  */
97 
98  void clear()
99  {
100  total_time = 0.0;
101  entries.clear();
102  }
103 };
104 
106  public:
108  NamedNestedSampleStats(const string &name, uint64_t samples);
109 
110  NamedNestedSampleStats &add_entry(const string &name, uint64_t samples);
111 
112  /* Updates sum_samples recursively. */
113  void update_sum();
114 
115  string full_report(int indent_level = 0, uint64_t total_samples = 0);
116 
117  string name;
118 
119  /* self_samples contains only the samples that this specific event got,
120  * while sum_samples also includes the samples of all sub-entries. */
122 
124 };
125 
126 /* Named entry containing both a time-sample count for objects of a type and a
127  * total count of processed items.
128  * This allows to estimate the time spent per item. */
130  public:
132 
133  ustring name;
136 };
137 
138 /* Contains statistics about pairs of samples and counts as described above. */
140  public:
142 
143  string full_report(int indent_level = 0);
144  void add(const ustring &name, uint64_t samples, uint64_t hits);
145 
146  typedef unordered_map<ustring, NamedSampleCountPair, ustringHash> entry_map;
148 };
149 
150 /* Statistics about mesh in the render database. */
151 class MeshStats {
152  public:
153  MeshStats();
154 
155  /* Generate full human-readable report. */
156  string full_report(int indent_level = 0);
157 
158  /* Input geometry statistics, this is what is coming as an input to render
159  * from. say, Blender. This does not include runtime or engine specific
160  * memory like BVH.
161  */
163 };
164 
165 /* Statistics about images held in memory. */
166 class ImageStats {
167  public:
168  ImageStats();
169 
170  /* Generate full human-readable report. */
171  string full_report(int indent_level = 0);
172 
174 };
175 
176 /* Render process statistics. */
177 class RenderStats {
178  public:
179  RenderStats();
180 
181  /* Return full report as string. */
182  string full_report();
183 
184  /* Collect kernel sampling information from Stats. */
185  void collect_profiling(Scene *scene, Profiler &prof);
186 
188 
194 };
195 
197  public:
198  /* Generate full human-readable report. */
199  string full_report(int indent_level = 0);
200 
202 };
203 
205  public:
207 
223 
224  string full_report();
225 
226  void clear();
227 };
228 
230 
231 #endif /* __RENDER_STATS_H__ */
string full_report(int indent_level=0)
Definition: stats.cpp:247
NamedSizeStats textures
Definition: stats.h:173
ImageStats()
Definition: stats.cpp:243
NamedSizeStats geometry
Definition: stats.h:162
MeshStats()
Definition: stats.cpp:229
string full_report(int indent_level=0)
Definition: stats.cpp:233
string full_report(int indent_level=0, uint64_t total_samples=0)
Definition: stats.cpp:144
uint64_t self_samples
Definition: stats.h:121
vector< NamedNestedSampleStats > entries
Definition: stats.h:123
uint64_t sum_samples
Definition: stats.h:121
NamedNestedSampleStats & add_entry(const string &name, uint64_t samples)
Definition: stats.cpp:129
uint64_t samples
Definition: stats.h:134
uint64_t hits
Definition: stats.h:135
NamedSampleCountPair(const ustring &name, uint64_t samples, uint64_t hits)
Definition: stats.cpp:175
entry_map entries
Definition: stats.h:147
string full_report(int indent_level=0)
Definition: stats.cpp:195
unordered_map< ustring, NamedSampleCountPair, ustringHash > entry_map
Definition: stats.h:146
void add(const ustring &name, uint64_t samples, uint64_t hits)
Definition: stats.cpp:184
NamedSizeEntry()
Definition: stats.cpp:56
size_t size
Definition: stats.h:41
string name
Definition: stats.h:40
void add_entry(const NamedSizeEntry &entry)
Definition: stats.cpp:78
size_t total_size
Definition: stats.h:68
string full_report(int indent_level=0)
Definition: stats.cpp:84
NamedSizeStats()
Definition: stats.cpp:74
vector< NamedSizeEntry > entries
Definition: stats.h:73
double time
Definition: stats.h:50
NamedTimeEntry()
Definition: stats.cpp:64
string name
Definition: stats.h:49
double total_time
Definition: stats.h:91
void clear()
Definition: stats.h:98
string full_report(int indent_level=0)
Definition: stats.cpp:104
void add_entry(const NamedTimeEntry &entry)
Definition: stats.h:81
vector< NamedTimeEntry > entries
Definition: stats.h:96
UpdateTimeStats tables
Definition: stats.h:221
UpdateTimeStats image
Definition: stats.h:209
UpdateTimeStats background
Definition: stats.h:212
UpdateTimeStats light
Definition: stats.h:210
UpdateTimeStats bake
Definition: stats.h:213
UpdateTimeStats film
Definition: stats.h:215
UpdateTimeStats camera
Definition: stats.h:214
UpdateTimeStats geometry
Definition: stats.h:208
string full_report()
Definition: stats.cpp:361
UpdateTimeStats particles
Definition: stats.h:218
UpdateTimeStats procedurals
Definition: stats.h:222
UpdateTimeStats integrator
Definition: stats.h:216
UpdateTimeStats osl
Definition: stats.h:217
void clear()
Definition: stats.cpp:382
UpdateTimeStats object
Definition: stats.h:211
UpdateTimeStats scene
Definition: stats.h:219
UpdateTimeStats svm
Definition: stats.h:220
NamedTimeStats times
Definition: stats.h:201
string full_report(int indent_level=0)
Definition: stats.cpp:352
Scene scene
#define CCL_NAMESPACE_END
unsigned __int64 uint64_t
Definition: stdint.h:93
void collect_profiling(Scene *scene, Profiler &prof)
Definition: stats.cpp:262
bool has_profiling
Definition: stats.h:187
string full_report()
Definition: stats.cpp:332
NamedSampleCountStats shaders
Definition: stats.h:192
NamedNestedSampleStats kernel
Definition: stats.h:191
MeshStats mesh
Definition: stats.h:189
RenderStats()
Definition: stats.cpp:257
ImageStats image
Definition: stats.h:190
NamedSampleCountStats objects
Definition: stats.h:193