31 const Depsgraph *graph;
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;
63string gnuplotify_id_code(
const string &name)
65 return string(
"") + name[0] + name[1];
68string gnuplotify_name(
const string &name)
71 const int length = name.length();
72 for (
int i = 0; i <
length; i++) {
73 const char ch = name[i];
82void write_stats_data(
const DebugContext &ctx)
85 Vector<StatsEntry> stats;
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);
98 std::sort(stats.begin(), stats.end(), stat_entry_comparator);
100 stats.resize(
min_ii(stats.size(), 32));
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);
146 deg::DebugContext ctx;
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.
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
local_group_size(16, 16) .push_constant(Type b
void DEG_debug_stats_gnuplot(const Depsgraph *depsgraph, FILE *fp, const char *label, const char *output_filename)
const char * output_filename
const Depsgraph * depsgraph