57 void deg_debug_fprintf(
const DebugContext &ctx,
const char *fmt, ...)
ATTR_PRINTF_FORMAT(2, 3);
58 void deg_debug_fprintf(const DebugContext &ctx, const
char *fmt, ...)
62 vfprintf(ctx.file, fmt, args);
66 inline double get_node_time(
const DebugContext & ,
const Node *
node)
73 bool stat_entry_comparator(
const StatsEntry &
a,
const StatsEntry &b)
75 return a.time > b.time;
78 string gnuplotify_id_code(
const string &name)
80 return string(
"") + name[0] + name[1];
83 string gnuplotify_name(
const string &name)
86 const int length = name.length();
87 for (
int i = 0; i <
length; i++) {
88 const char ch = name[i];
97 void write_stats_data(
const DebugContext &ctx)
100 Vector<StatsEntry> stats;
101 stats.reserve(ctx.graph->id_nodes.size());
102 for (
const IDNode *
id_node : ctx.graph->id_nodes) {
113 std::sort(stats.begin(), stats.end(), stat_entry_comparator);
115 stats.resize(
min_ii(stats.size(), 32));
116 std::reverse(stats.begin(), stats.end());
118 deg_debug_fprintf(ctx,
"$data << EOD" NL);
119 for (
const StatsEntry &entry : stats) {
120 deg_debug_fprintf(ctx,
122 gnuplotify_id_code(entry.id_node->id_orig->name).c_str(),
123 gnuplotify_name(entry.id_node->id_orig->name + 2).c_str(),
126 deg_debug_fprintf(ctx,
"EOD" NL);
129 void deg_debug_stats_gnuplot(
const DebugContext &ctx)
132 write_stats_data(ctx);
134 if (ctx.label && ctx.label[0]) {
135 deg_debug_fprintf(ctx,
"set title \"%s\"" NL, ctx.label);
139 deg_debug_fprintf(ctx,
"set terminal pngcairo size 1920,1080" NL);
140 deg_debug_fprintf(ctx,
"set output \"%s\"" NL, ctx.output_filename);
141 deg_debug_fprintf(ctx,
"set grid" NL);
142 deg_debug_fprintf(ctx,
"set datafile separator ','" NL);
143 deg_debug_fprintf(ctx,
"set style fill solid" NL);
144 deg_debug_fprintf(ctx,
145 "plot \"$data\" using "
146 "($2*0.5):0:($2*0.5):(0.2):yticlabels(1) "
147 "with boxxyerrorbars t '' lt rgb \"#406090\"" NL);
161 deg::DebugContext ctx;
166 deg::deg_debug_stats_gnuplot(ctx);
MINLINE int min_ii(int a, int b)
size_t ATTR_PRINTF_FORMAT(3, 4)
struct Depsgraph Depsgraph
ID and Library types, which are fundamental for sdna.
void sort(btMatrix3x3 &U, btVector3 &sigma, btMatrix3x3 &V, int t)
Helper function of 3X3 SVD for sorting singular values.
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
void DEG_debug_stats_gnuplot(const Depsgraph *depsgraph, FILE *fp, const char *label, const char *output_filename)
const char * output_filename
const Depsgraph * depsgraph