Blender V4.3
COM_profiler.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include "BLI_map.hh"
8#include "BLI_timeit.hh"
9
10#include "DNA_node_types.h"
11
13
15
16class Context;
17
18/* -------------------------------------------------------------------------------------------------
19 * Profiler
20 *
21 * A class that profiles the evaluation of the compositor and tracks information like the
22 * evaluation time of every node. */
23class Profiler {
24 private:
25 /* Stores the evaluation time of each node instance keyed by its instance key. Note that
26 * pixel-wise nodes like Math nodes will not be measured, that's because they are compiled
27 * together with other pixel-wise operations in a single operation, so we can't measure the
28 * evaluation time of each individual node. */
29 Map<bNodeInstanceKey, timeit::Nanoseconds> nodes_evaluation_times_;
30
31 public:
32 /* Returns a reference to the nodes evaluation times. */
34
35 /* Set the evaluation time of the node identified by the given node instance key. */
37
38 /* Finalize profiling by computing node group times. This should be called after evaluation. */
39 void finalize(const bNodeTree &node_tree);
40
41 private:
42 /* Computes the evaluation time of every group node inside the given tree recursively by
43 * accumulating the evaluation time of its nodes, setting the computed time to the group nodes.
44 * The time is returned since the method is called recursively. */
45 timeit::Nanoseconds accumulate_node_group_times(const bNodeTree &node_tree,
46 bNodeInstanceKey instance_key);
47};
48
49} // namespace blender::realtime_compositor
void finalize(const bNodeTree &node_tree)
Definition profiler.cc:66
void set_node_evaluation_time(bNodeInstanceKey node_instance_key, timeit::Nanoseconds time)
Definition profiler.cc:23
Map< bNodeInstanceKey, timeit::Nanoseconds > & get_nodes_evaluation_times()
Definition profiler.cc:18
std::chrono::nanoseconds Nanoseconds
Definition BLI_timeit.hh:16