Blender V5.0
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
12namespace blender::compositor {
13
14class Context;
15
16/* -------------------------------------------------------------------------------------------------
17 * Profiler
18 *
19 * A class that profiles the evaluation of the compositor and tracks information like the
20 * evaluation time of every node. */
21class Profiler {
22 private:
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_;
28
29 public:
30 /* Returns a reference to the nodes evaluation times. */
32
33 /* Set the evaluation time of the node identified by the given node instance key. */
35
36 /* Finalize profiling by computing node group times. This should be called after evaluation. */
37 void finalize(const bNodeTree &node_tree);
38
39 private:
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);
45};
46
47} // namespace blender::compositor
void finalize(const bNodeTree &node_tree)
Definition profiler.cc:65
void set_node_evaluation_time(bNodeInstanceKey node_instance_key, timeit::Nanoseconds time)
Definition profiler.cc:22
Map< bNodeInstanceKey, timeit::Nanoseconds > & get_nodes_evaluation_times()
Definition profiler.cc:17
std::chrono::nanoseconds Nanoseconds
Definition BLI_timeit.hh:21