31 const Depsgraph *graph;
33 const char *output_filename;
37 const IDNode *id_node;
42void deg_debug_fprintf(
const DebugContext &ctx,
const char *fmt, ...)
ATTR_PRINTF_FORMAT(2, 3);
43void deg_debug_fprintf(
const DebugContext &ctx,
const char *fmt, ...)
47 vfprintf(ctx.file, fmt, args);
51inline double get_node_time(
const DebugContext & ,
const Node *node)
55 return node->stats.current_time;
58bool stat_entry_comparator(
const StatsEntry &a,
const StatsEntry &
b)
60 return a.time >
b.time;
63std::string gnuplotify_id_code(
const std::string &
name)
65 return std::string(
"") +
name[0] +
name[1];
68std::string gnuplotify_name(
const std::string &
name)
73 const char ch =
name[
i];
82void write_stats_data(
const DebugContext &ctx)
86 stats.
reserve(ctx.graph->id_nodes.size());
87 for (
const IDNode *id_node : ctx.graph->id_nodes) {
88 const double time = get_node_time(ctx, id_node);
93 entry.id_node = id_node;
98 std::sort(stats.
begin(), stats.
end(), stat_entry_comparator);
101 std::reverse(stats.
begin(), stats.
end());
103 deg_debug_fprintf(ctx,
"$data << EOD" NL);
104 for (
const StatsEntry &entry : stats) {
105 deg_debug_fprintf(ctx,
107 gnuplotify_id_code(entry.id_node->id_orig->name).c_str(),
108 gnuplotify_name(entry.id_node->id_orig->name + 2).c_str(),
111 deg_debug_fprintf(ctx,
"EOD" NL);
114void deg_debug_stats_gnuplot(
const DebugContext &ctx)
117 write_stats_data(ctx);
119 if (ctx.label && ctx.label[0]) {
120 deg_debug_fprintf(ctx,
"set title \"%s\"" NL, ctx.label);
124 deg_debug_fprintf(ctx,
"set terminal pngcairo size 1920,1080" NL);
125 deg_debug_fprintf(ctx,
"set output \"%s\"" NL, ctx.output_filename);
126 deg_debug_fprintf(ctx,
"set grid" NL);
127 deg_debug_fprintf(ctx,
"set datafile separator ','" NL);
128 deg_debug_fprintf(ctx,
"set style fill solid" NL);
129 deg_debug_fprintf(ctx,
130 "plot \"$data\" using "
131 "($2*0.5):0:($2*0.5):(0.2):yticlabels(1) "
132 "with boxxyerrorbars t '' lt rgb \"#406090\"" NL);
141 const char *output_filename)
146 deg::DebugContext ctx;
150 ctx.output_filename = output_filename;
151 deg::deg_debug_stats_gnuplot(ctx);
#define ATTR_PRINTF_FORMAT(format_param, dots_param)
MINLINE int min_ii(int a, int b)
ID and Library types, which are fundamental for SDNA.
BPy_StructRNA * depsgraph
void append(const T &value)
void resize(const int64_t new_size)
void reserve(const int64_t min_capacity)
void DEG_debug_stats_gnuplot(const Depsgraph *depsgraph, FILE *fp, const char *label, const char *output_filename)
float length(VecOp< float, D >) RET