Blender V5.0
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.h"
12#include "BLI_hash.h"
13#include "BLI_string.h"
14#include "BLI_time.h"
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 if (!do_time_debug()) {
30 return;
31 }
32
33 const double current_time = BLI_time_now_seconds();
34
35 graph_evaluation_start_time_ = current_time;
36}
37
39{
40 if (!do_time_debug()) {
41 return;
42 }
43
44 const double graph_eval_end_time = BLI_time_now_seconds();
45 const double graph_eval_time = graph_eval_end_time - graph_evaluation_start_time_;
46
47 if (name.empty()) {
48 printf("Depsgraph updated in %f seconds.\n", graph_eval_time);
49 }
50 else {
51 printf("Depsgraph [%s] updated in %f seconds.\n", name.c_str(), graph_eval_time);
52 }
53}
54
56{
57 return (G.debug & G_DEBUG_DEPSGRAPH_PRETTY) != 0;
58}
59
60std::string color_for_pointer(const void *pointer)
61{
62 if (!terminal_do_color()) {
63 return "";
64 }
65 int r, g, b;
66 BLI_hash_pointer_to_color(pointer, &r, &g, &b);
67 char buffer[64];
69 return std::string(buffer);
70}
71
72std::string color_end()
73{
74 if (!terminal_do_color()) {
75 return "";
76 }
77 return std::string(TRUECOLOR_ANSI_COLOR_FINISH);
78}
79
80} // 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:18
#define TRUECOLOR_ANSI_COLOR_FORMAT
Definition BLI_console.h:15
BLI_INLINE void BLI_hash_pointer_to_color(const void *ptr, int *r, int *g, int *b)
Definition BLI_hash.h:97
#define SNPRINTF(dst, format,...)
Definition BLI_string.h:604
Platform independent time functions.
double BLI_time_now_seconds(void)
Definition time.cc:113
#define printf(...)
#define G(x, y, z)
std::string color_end()
Definition deg_debug.cc:72
bool terminal_do_color()
Definition deg_debug.cc:55
std::string color_for_pointer(const void *pointer)
Definition deg_debug.cc:60