Blender V5.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
8
10
11#include "BLI_console.hh"
12#include "BLI_hash_c.hh"
13#include "BLI_string.hh"
14#include "BLI_time.hh"
15
16#include "BKE_global.hh"
17
18namespace blender::deg {
19
21
23{
24 return ((G.debug & G_DEBUG_DEPSGRAPH_TIME) != 0);
25}
26
28{
29 const double current_time = BLI_time_now_seconds();
30
31 graph_evaluation_start_time_ = current_time;
32}
33
35{
36 const double graph_eval_end_time = BLI_time_now_seconds();
38
39 if (!do_time_debug()) {
40 return;
41 }
42
43 if (name.empty()) {
44 printf("Depsgraph updated in %f seconds.\n", graph_evaluation_total_time_);
45 }
46 else {
47 printf("Depsgraph [%s] updated in %f seconds.\n", name.c_str(), graph_evaluation_total_time_);
48 }
49}
50
55
57{
58 return (G.debug & G_DEBUG_DEPSGRAPH_PRETTY) != 0;
59}
60
61std::string color_for_pointer(const void *pointer)
62{
63 if (!terminal_do_color()) {
64 return "";
65 }
66 int r, g, b;
67 BLI_hash_pointer_to_color(pointer, &r, &g, &b);
68 char buffer[64];
70 return std::string(buffer);
71}
72
73std::string color_end()
74{
75 if (!terminal_do_color()) {
76 return "";
77 }
78 return std::string(TRUECOLOR_ANSI_COLOR_FINISH);
79}
80
81} // namespace blender::deg
Set of utility functions and constants to work with consoles.
#define TRUECOLOR_ANSI_COLOR_FINISH
#define TRUECOLOR_ANSI_COLOR_FORMAT
#define SNPRINTF(dst, format,...)
Platform independent time functions.
double total_evaluation_time() const
Definition deg_debug.cc:51
std::string color_end()
Definition deg_debug.cc:73
bool terminal_do_color()
Definition deg_debug.cc:56
std::string color_for_pointer(const void *pointer)
Definition deg_debug.cc:61
BLI_INLINE void BLI_hash_pointer_to_color(const void *ptr, int *r, int *g, int *b)
Definition BLI_hash_c.hh:99
@ G_DEBUG_DEPSGRAPH_PRETTY
@ G_DEBUG_DEPSGRAPH_TIME
Global G
Definition blender.cc:57
double BLI_time_now_seconds()
Definition time.cc:30