41 void deg_debug_fprintf(
const DebugContext &ctx,
const char *fmt, ...)
ATTR_PRINTF_FORMAT(2, 3);
42 void deg_debug_fprintf(const DebugContext &ctx, const
char *fmt, ...)
46 vfprintf(ctx.file, fmt, args);
50 inline double get_node_time(
const DebugContext & ,
const Node *
node)
57 bool stat_entry_comparator(
const StatsEntry &
a,
const StatsEntry &
b)
59 return a.time >
b.time;
62 string gnuplotify_id_code(
const string &name)
64 return string(
"") + name[0] + name[1];
67 string gnuplotify_name(
const string &name)
70 const int length = name.length();
71 for (
int i = 0; i <
length; i++) {
72 const char ch = name[i];
81 void write_stats_data(
const DebugContext &ctx)
84 Vector<StatsEntry> stats;
85 stats.reserve(ctx.graph->id_nodes.size());
86 for (
const IDNode *
id_node : ctx.graph->id_nodes) {
97 std::sort(stats.begin(), stats.end(), stat_entry_comparator);
99 stats.resize(
min_ii(stats.size(), 32));
100 std::reverse(stats.begin(), stats.end());
102 deg_debug_fprintf(ctx,
"$data << EOD" NL);
103 for (
const StatsEntry &entry : stats) {
104 deg_debug_fprintf(ctx,
106 gnuplotify_id_code(entry.id_node->id_orig->name).c_str(),
107 gnuplotify_name(entry.id_node->id_orig->name + 2).c_str(),
110 deg_debug_fprintf(ctx,
"EOD" NL);
113 void deg_debug_stats_gnuplot(
const DebugContext &ctx)
116 write_stats_data(ctx);
118 if (ctx.label && ctx.label[0]) {
119 deg_debug_fprintf(ctx,
"set title \"%s\"" NL, ctx.label);
123 deg_debug_fprintf(ctx,
"set terminal pngcairo size 1920,1080" NL);
124 deg_debug_fprintf(ctx,
"set output \"%s\"" NL, ctx.output_filename);
125 deg_debug_fprintf(ctx,
"set grid" NL);
126 deg_debug_fprintf(ctx,
"set datafile separator ','" NL);
127 deg_debug_fprintf(ctx,
"set style fill solid" NL);
128 deg_debug_fprintf(ctx,
129 "plot \"$data\" using "
130 "($2*0.5):0:($2*0.5):(0.2):yticlabels(1) "
131 "with boxxyerrorbars t '' lt rgb \"#406090\"" NL);
145 deg::DebugContext ctx;
150 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.
void DEG_debug_stats_gnuplot(const Depsgraph *depsgraph, FILE *fp, const char *label, const char *output_filename)
const char * output_filename
const Depsgraph * depsgraph
T length(const vec_base< T, Size > &a)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)