Blender V5.0
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#pragma once
6
7#include "scene/scene.h"
8
9#include "util/string.h"
10#include "util/vector.h"
11
13
14/* Named statistics entry, which corresponds to a size. There is no real
15 * semantic around the units of size, it just should be the same for all
16 * entries.
17 *
18 * This is a generic entry for all size-related statistics, which helps
19 * avoiding duplicating code for things like sorting.
20 */
22 public:
24 NamedSizeEntry(const string &name, const size_t size);
25
26 string name;
27 size_t size;
28};
29
31 public:
33 NamedTimeEntry(const string &name, const double time);
34
35 string name;
36 double time;
37};
38
39/* Container of named size entries. Used, for example, to store per-mesh memory
40 * usage statistics. But also keeps track of overall memory usage of the
41 * container.
42 */
44 public:
46
47 /* Add entry to the statistics. */
48 void add_entry(const NamedSizeEntry &entry);
49
50 /* Generate full human-readable report. */
51 string full_report(const int indent_level = 0);
52
53 /* Total size of all entries. */
54 size_t total_size;
55
56 /* NOTE: Is fine to read directly, but for adding use add_entry(), which
57 * makes sure all accumulating values are properly updated.
58 */
60};
61
63 public:
65
66 /* Add entry to the statistics. */
67 void add_entry(const NamedTimeEntry &entry)
68 {
69 total_time += entry.time;
70 entries.push_back(entry);
71 }
72
73 /* Generate full human-readable report. */
74 string full_report(const int indent_level = 0);
75
76 /* Total time of all entries. */
77 double total_time;
78
79 /* NOTE: Is fine to read directly, but for adding use add_entry(), which
80 * makes sure all accumulating values are properly updated.
81 */
83
84 void clear()
85 {
86 total_time = 0.0;
87 entries.clear();
88 }
89};
90
92 public:
94 NamedNestedSampleStats(const string &name, const uint64_t samples);
95
96 NamedNestedSampleStats &add_entry(const string &name, const uint64_t samples);
97
98 /* Updates sum_samples recursively. */
99 void update_sum();
100
101 string full_report(const int indent_level = 0, const uint64_t total_samples = 0);
102
103 string name;
104
105 /* self_samples contains only the samples that this specific event got,
106 * while sum_samples also includes the samples of all sub-entries. */
108
110};
111
112/* Named entry containing both a time-sample count for objects of a type and a
113 * total count of processed items.
114 * This allows to estimate the time spent per item. */
116 public:
117 NamedSampleCountPair(const ustring &name, const uint64_t samples, const uint64_t hits);
118
119 ustring name;
122};
123
124/* Contains statistics about pairs of samples and counts as described above. */
126 public:
128
129 string full_report(const int indent_level = 0);
130 void add(const ustring &name, const uint64_t samples, const uint64_t hits);
131
132 using entry_map = unordered_map<ustring, NamedSampleCountPair>;
134};
135
136/* Statistics about mesh in the render database. */
138 public:
140
141 /* Generate full human-readable report. */
142 string full_report(const int indent_level = 0);
143
144 /* Input geometry statistics, this is what is coming as an input to render
145 * from. say, Blender. This does not include runtime or engine specific
146 * memory like BVH.
147 */
149};
150
151/* Statistics about images held in memory. */
153 public:
155
156 /* Generate full human-readable report. */
157 string full_report(const int indent_level = 0);
158
160};
161
162/* Render process statistics. */
163class RenderStats {
164 public:
165 RenderStats();
166
167 /* Return full report as string. */
168 string full_report();
169
170 /* Collect kernel sampling information from Stats. */
171 void collect_profiling(Scene *scene, Profiler &prof);
172
174
180};
181
183 public:
184 /* Generate full human-readable report. */
185 string full_report(const int indent_level = 0);
186
188};
189
214
unsigned long long int uint64_t
NamedSizeStats textures
string full_report(const int indent_level=0)
Definition stats.cpp:220
string full_report(const int indent_level=0)
Definition stats.cpp:208
NamedSizeStats geometry
vector< NamedNestedSampleStats > entries
NamedNestedSampleStats & add_entry(const string &name, const uint64_t samples)
Definition stats.cpp:105
string full_report(const int indent_level=0, const uint64_t total_samples=0)
Definition stats.cpp:120
NamedSampleCountPair(const ustring &name, const uint64_t samples, const uint64_t hits)
Definition stats.cpp:151
string full_report(const int indent_level=0)
Definition stats.cpp:171
unordered_map< ustring, NamedSampleCountPair > entry_map
void add(const ustring &name, const uint64_t samples, const uint64_t hits)
Definition stats.cpp:160
void add_entry(const NamedSizeEntry &entry)
Definition stats.cpp:56
string full_report(const int indent_level=0)
Definition stats.cpp:62
size_t total_size
Definition scene/stats.h:54
vector< NamedSizeEntry > entries
Definition scene/stats.h:59
double total_time
Definition scene/stats.h:77
void add_entry(const NamedTimeEntry &entry)
Definition scene/stats.h:67
string full_report(const int indent_level=0)
Definition stats.cpp:82
vector< NamedTimeEntry > entries
Definition scene/stats.h:82
UpdateTimeStats tables
UpdateTimeStats image
UpdateTimeStats background
UpdateTimeStats light
UpdateTimeStats film
UpdateTimeStats camera
UpdateTimeStats geometry
string full_report()
Definition stats.cpp:315
UpdateTimeStats particles
UpdateTimeStats procedurals
UpdateTimeStats integrator
UpdateTimeStats osl
UpdateTimeStats object
UpdateTimeStats scene
UpdateTimeStats svm
string full_report(const int indent_level=0)
Definition stats.cpp:308
NamedTimeStats times
#define CCL_NAMESPACE_END
const char * name
void collect_profiling(Scene *scene, Profiler &prof)
Definition stats.cpp:235
bool has_profiling
string full_report()
Definition stats.cpp:290
NamedSampleCountStats shaders
NamedNestedSampleStats kernel
MeshStats mesh
ImageStats image
NamedSampleCountStats objects