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