Blender  V3.3
scene/stats.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #ifndef __RENDER_STATS_H__
5 #define __RENDER_STATS_H__
6 
7 #include "scene/scene.h"
8 
9 #include "util/stats.h"
10 #include "util/string.h"
11 #include "util/vector.h"
12 
14 
15 /* Named statistics entry, which corresponds to a size. There is no real
16  * semantic around the units of size, it just should be the same for all
17  * entries.
18  *
19  * This is a generic entry for all size-related statistics, which helps
20  * avoiding duplicating code for things like sorting.
21  */
23  public:
25  NamedSizeEntry(const string &name, size_t size);
26 
27  string name;
28  size_t size;
29 };
30 
32  public:
34  NamedTimeEntry(const string &name, double time);
35 
36  string name;
37  double time;
38 };
39 
40 /* Container of named size entries. Used, for example, to store per-mesh memory
41  * usage statistics. But also keeps track of overall memory usage of the
42  * container.
43  */
45  public:
47 
48  /* Add entry to the statistics. */
49  void add_entry(const NamedSizeEntry &entry);
50 
51  /* Generate full human-readable report. */
52  string full_report(int indent_level = 0);
53 
54  /* Total size of all entries. */
55  size_t total_size;
56 
57  /* NOTE: Is fine to read directly, but for adding use add_entry(), which
58  * makes sure all accumulating values are properly updated.
59  */
61 };
62 
64  public:
66 
67  /* Add entry to the statistics. */
68  void add_entry(const NamedTimeEntry &entry)
69  {
70  total_time += entry.time;
71  entries.push_back(entry);
72  }
73 
74  /* Generate full human-readable report. */
75  string full_report(int indent_level = 0);
76 
77  /* Total time of all entries. */
78  double total_time;
79 
80  /* NOTE: Is fine to read directly, but for adding use add_entry(), which
81  * makes sure all accumulating values are properly updated.
82  */
84 
85  void clear()
86  {
87  total_time = 0.0;
88  entries.clear();
89  }
90 };
91 
93  public:
95  NamedNestedSampleStats(const string &name, uint64_t samples);
96 
97  NamedNestedSampleStats &add_entry(const string &name, uint64_t samples);
98 
99  /* Updates sum_samples recursively. */
100  void update_sum();
101 
102  string full_report(int indent_level = 0, uint64_t total_samples = 0);
103 
104  string name;
105 
106  /* self_samples contains only the samples that this specific event got,
107  * while sum_samples also includes the samples of all sub-entries. */
109 
111 };
112 
113 /* Named entry containing both a time-sample count for objects of a type and a
114  * total count of processed items.
115  * This allows to estimate the time spent per item. */
117  public:
119 
120  ustring name;
123 };
124 
125 /* Contains statistics about pairs of samples and counts as described above. */
127  public:
129 
130  string full_report(int indent_level = 0);
131  void add(const ustring &name, uint64_t samples, uint64_t hits);
132 
133  typedef unordered_map<ustring, NamedSampleCountPair, ustringHash> entry_map;
135 };
136 
137 /* Statistics about mesh in the render database. */
138 class MeshStats {
139  public:
140  MeshStats();
141 
142  /* Generate full human-readable report. */
143  string full_report(int indent_level = 0);
144 
145  /* Input geometry statistics, this is what is coming as an input to render
146  * from. say, Blender. This does not include runtime or engine specific
147  * memory like BVH.
148  */
150 };
151 
152 /* Statistics about images held in memory. */
153 class ImageStats {
154  public:
155  ImageStats();
156 
157  /* Generate full human-readable report. */
158  string full_report(int indent_level = 0);
159 
161 };
162 
163 /* Render process statistics. */
164 class RenderStats {
165  public:
166  RenderStats();
167 
168  /* Return full report as string. */
169  string full_report();
170 
171  /* Collect kernel sampling information from Stats. */
172  void collect_profiling(Scene *scene, Profiler &prof);
173 
175 
181 };
182 
184  public:
185  /* Generate full human-readable report. */
186  string full_report(int indent_level = 0);
187 
189 };
190 
192  public:
194 
210 
211  string full_report();
212 
213  void clear();
214 };
215 
217 
218 #endif /* __RENDER_STATS_H__ */
string full_report(int indent_level=0)
Definition: stats.cpp:234
NamedSizeStats textures
Definition: scene/stats.h:160
ImageStats()
Definition: stats.cpp:230
NamedSizeStats geometry
Definition: scene/stats.h:149
MeshStats()
Definition: stats.cpp:216
string full_report(int indent_level=0)
Definition: stats.cpp:220
string full_report(int indent_level=0, uint64_t total_samples=0)
Definition: stats.cpp:131
vector< NamedNestedSampleStats > entries
Definition: scene/stats.h:110
NamedNestedSampleStats & add_entry(const string &name, uint64_t samples)
Definition: stats.cpp:116
NamedSampleCountPair(const ustring &name, uint64_t samples, uint64_t hits)
Definition: stats.cpp:162
string full_report(int indent_level=0)
Definition: stats.cpp:182
unordered_map< ustring, NamedSampleCountPair, ustringHash > entry_map
Definition: scene/stats.h:133
void add(const ustring &name, uint64_t samples, uint64_t hits)
Definition: stats.cpp:171
NamedSizeEntry()
Definition: stats.cpp:43
void add_entry(const NamedSizeEntry &entry)
Definition: stats.cpp:65
size_t total_size
Definition: scene/stats.h:55
string full_report(int indent_level=0)
Definition: stats.cpp:71
NamedSizeStats()
Definition: stats.cpp:61
vector< NamedSizeEntry > entries
Definition: scene/stats.h:60
NamedTimeEntry()
Definition: stats.cpp:51
double total_time
Definition: scene/stats.h:78
string full_report(int indent_level=0)
Definition: stats.cpp:91
void add_entry(const NamedTimeEntry &entry)
Definition: scene/stats.h:68
vector< NamedTimeEntry > entries
Definition: scene/stats.h:83
UpdateTimeStats tables
Definition: scene/stats.h:208
UpdateTimeStats image
Definition: scene/stats.h:196
UpdateTimeStats background
Definition: scene/stats.h:199
UpdateTimeStats light
Definition: scene/stats.h:197
UpdateTimeStats bake
Definition: scene/stats.h:200
UpdateTimeStats film
Definition: scene/stats.h:202
UpdateTimeStats camera
Definition: scene/stats.h:201
UpdateTimeStats geometry
Definition: scene/stats.h:195
string full_report()
Definition: stats.cpp:329
UpdateTimeStats particles
Definition: scene/stats.h:205
UpdateTimeStats procedurals
Definition: scene/stats.h:209
UpdateTimeStats integrator
Definition: scene/stats.h:203
UpdateTimeStats osl
Definition: scene/stats.h:204
void clear()
Definition: stats.cpp:350
UpdateTimeStats object
Definition: scene/stats.h:198
UpdateTimeStats scene
Definition: scene/stats.h:206
UpdateTimeStats svm
Definition: scene/stats.h:207
NamedTimeStats times
Definition: scene/stats.h:188
string full_report(int indent_level=0)
Definition: stats.cpp:320
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
Scene scene
unsigned __int64 uint64_t
Definition: stdint.h:90
void collect_profiling(Scene *scene, Profiler &prof)
Definition: stats.cpp:249
bool has_profiling
Definition: scene/stats.h:174
string full_report()
Definition: stats.cpp:300
NamedSampleCountStats shaders
Definition: scene/stats.h:179
NamedNestedSampleStats kernel
Definition: scene/stats.h:178
MeshStats mesh
Definition: scene/stats.h:176
RenderStats()
Definition: stats.cpp:244
ImageStats image
Definition: scene/stats.h:177
NamedSampleCountStats objects
Definition: scene/stats.h:180