Depsgraph: Escape underscore in time stats chart

This commit is contained in:
Sergey Sharybin
2018-08-24 10:16:05 +02:00
parent b8c9df6f21
commit 6e3569d9f4

View File

@@ -87,6 +87,25 @@ bool stat_entry_comparator(const StatsEntry& a, const StatsEntry& b)
return a.time < b.time;
}
string gnuplotify_id_code(const string& name)
{
return string("") + name[0] + name [1];
}
string gnuplotify_name(const string& name)
{
string result = "";
const int length = name.length();
for (int i = 0; i < length; ++i) {
const char ch = name[i];
if (ch == '_') {
result += "\\\\\\";
}
result += ch;
}
return result;
}
void write_stats_data(const DebugContext& ctx)
{
// Fill in array of all stats which are to be displayed.
@@ -109,8 +128,10 @@ void write_stats_data(const DebugContext& ctx)
// Print data to the file stream.
deg_debug_fprintf(ctx, "$data << EOD" NL);
foreach (const StatsEntry& entry, stats) {
deg_debug_fprintf(ctx, "\"%s\",%f" NL,
entry.id_node->id_orig->name + 2,
deg_debug_fprintf(
ctx, "\"[%s] %s\",%f" NL,
gnuplotify_id_code(entry.id_node->id_orig->name).c_str(),
gnuplotify_name(entry.id_node->id_orig->name + 2).c_str(),
entry.time);
}
deg_debug_fprintf(ctx, "EOD" NL);