Blender V4.3
deg_debug.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2013 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include "BLI_console.h"
12#include "BLI_hash.h"
13#include "BLI_string.h"
15#include "BLI_utildefines.h"
16
17#include "BKE_global.hh"
18
19#include "intern/depsgraph.hh"
20
21namespace blender::deg {
22
23DepsgraphDebug::DepsgraphDebug() : flags(G.debug), graph_evaluation_start_time_(0) {}
24
26{
27 return ((G.debug & G_DEBUG_DEPSGRAPH_TIME) != 0);
28}
29
31{
32 if (!do_time_debug()) {
33 return;
34 }
35
36 const double current_time = BLI_time_now_seconds();
37
38 graph_evaluation_start_time_ = current_time;
39}
40
42{
43 if (!do_time_debug()) {
44 return;
45 }
46
47 const double graph_eval_end_time = BLI_time_now_seconds();
48 const double graph_eval_time = graph_eval_end_time - graph_evaluation_start_time_;
49
50 if (name.empty()) {
51 printf("Depsgraph updated in %f seconds.\n", graph_eval_time);
52 }
53 else {
54 printf("Depsgraph [%s] updated in %f seconds.\n", name.c_str(), graph_eval_time);
55 }
56}
57
59{
60 return (G.debug & G_DEBUG_DEPSGRAPH_PRETTY) != 0;
61}
62
63string color_for_pointer(const void *pointer)
64{
65 if (!terminal_do_color()) {
66 return "";
67 }
68 int r, g, b;
69 BLI_hash_pointer_to_color(pointer, &r, &g, &b);
70 char buffer[64];
72 return string(buffer);
73}
74
75string color_end()
76{
77 if (!terminal_do_color()) {
78 return "";
79 }
80 return string(TRUECOLOR_ANSI_COLOR_FINISH);
81}
82
83} // namespace blender::deg
@ G_DEBUG_DEPSGRAPH_PRETTY
@ G_DEBUG_DEPSGRAPH_TIME
Set of utility functions and constants to work with consoles.
#define TRUECOLOR_ANSI_COLOR_FINISH
Definition BLI_console.h:22
#define TRUECOLOR_ANSI_COLOR_FORMAT
Definition BLI_console.h:19
BLI_INLINE void BLI_hash_pointer_to_color(const void *ptr, int *r, int *g, int *b)
Definition BLI_hash.h:101
#define SNPRINTF(dst, format,...)
Definition BLI_string.h:597
double BLI_time_now_seconds(void)
Definition time.c:65
Utility defines for timing/benchmarks.
local_group_size(16, 16) .push_constant(Type b
#define printf
#define G(x, y, z)
bool terminal_do_color()
Definition deg_debug.cc:58
string color_for_pointer(const void *pointer)
Definition deg_debug.cc:63
string color_end()
Definition deg_debug.cc:75