1 /* SPDX-FileCopyrightText: 2024 Blender Authors
3 * SPDX-License-Identifier: GPL-2.0-or-later */
8 #include "BLI_timeit.hh"
10 #include "DNA_node_types.h"
12 namespace blender::compositor
{
16 /* -------------------------------------------------------------------------------------------------
19 * A class that profiles the evaluation of the compositor and tracks information like the
20 * evaluation time of every node. */
23 /* Stores the evaluation time of each node instance keyed by its instance key. Note that
24 * pixel-wise nodes like Math nodes will not be measured, that's because they are compiled
25 * together with other pixel-wise operations in a single operation, so we can't measure the
26 * evaluation time of each individual node. */
27 Map
<bNodeInstanceKey
, timeit::Nanoseconds
> nodes_evaluation_times_
;
30 /* Returns a reference to the nodes evaluation times. */
31 Map
<bNodeInstanceKey
, timeit::Nanoseconds
> &get_nodes_evaluation_times();
33 /* Set the evaluation time of the node identified by the given node instance key. */
34 void set_node_evaluation_time(bNodeInstanceKey node_instance_key
, timeit::Nanoseconds time
);
36 /* Finalize profiling by computing node group times. This should be called after evaluation. */
37 void finalize(const bNodeTree
&node_tree
);
40 /* Computes the evaluation time of every group node inside the given tree recursively by
41 * accumulating the evaluation time of its nodes, setting the computed time to the group nodes.
42 * The time is returned since the method is called recursively. */
43 timeit::Nanoseconds
accumulate_node_group_times(const bNodeTree
&node_tree
,
44 bNodeInstanceKey instance_key
);
47 } // namespace blender::compositor