From 14e6a1d24b9aa01ad7756dd2089db7c5a680b416 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 13 Oct 2020 12:04:13 +0200 Subject: [PATCH] more statistics in sunburst chart --- libsrc/core/paje_trace.cpp | 42 ++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/libsrc/core/paje_trace.cpp b/libsrc/core/paje_trace.cpp index 3b285830..6840b16c 100644 --- a/libsrc/core/paje_trace.cpp +++ b/libsrc/core/paje_trace.cpp @@ -785,7 +785,11 @@ namespace ngcore { int id = 0; std::map children; + double chart_size = 0.0; // time without children (the chart lib accumulates children sizes again) double time = 0.0; + double min_time = 1e99; + double max_time = 0.0; + size_t calls = 0; std::string name; TTimePoint start_time = 0; }; @@ -793,7 +797,13 @@ namespace ngcore void PrintNode (const TreeNode &n, int &level, std::ofstream & f); void PrintNode (const TreeNode &n, int &level, std::ofstream & f) { - f << "{ name: \"" + n.name + "\", size: " + ToString(n.time); + f << "{ name: \"" + n.name + "\""; + f << ", calls: " << n.calls; + f << ", size: " << n.chart_size; + f << ", time: " << n.time; + f << ", min: " << n.min_time; + f << ", max: " << n.max_time; + f << ", avg: " << n.time/n.calls; int size = n.children.size(); if(size>0) { @@ -815,7 +825,6 @@ namespace ngcore std::vector events; TreeNode root; - root.time=0; root.name="all"; TreeNode *current = &root; @@ -853,6 +862,9 @@ namespace ngcore std::sort (events.begin(), events.end()); root.time = 1000.0*static_cast(stop_time) * seconds_per_tick; + root.calls = 1; + root.min_time = root.time; + root.max_time = root.time; for(auto & event : events) { @@ -883,12 +895,19 @@ namespace ngcore } double time = 1000.0*static_cast(event.time-current->start_time) * seconds_per_tick; current->time += time; + current->chart_size += time; + current->min_time = std::min(current->min_time, time); + current->max_time = std::max(current->max_time, time); + current->calls++; + current = node_stack.back(); - current->time -= time; + current->chart_size -= time; node_stack.pop_back(); } } + root.chart_size = 0.0; + int level = 0; std::ofstream f(tracefile_name+".html"); f.precision(4); @@ -910,11 +929,26 @@ namespace ngcore const color = d3.scaleOrdinal(d3.schemePaired); + let getTime = (t) => + { + if(t>=1000) return (t/1000).toPrecision(4) + ' s'; + if(t>=0.1) return t.toPrecision(4) + ' ms'; + if(t>=1e-4) return (t*1e3).toPrecision(4) + ' us'; + + return (t/1e6).toPrecision(4) + ' ns'; + }; + Sunburst() .data(data) .size('size') .color(d => color(d.name)) - .tooltipContent((d, node) => `Time: ${node.value.toPrecision(6)}ms`) + .tooltipContent((d, node) => { + return `Time: ${getTime(d.time)}
` + + `calls: ${d.calls}
` + + `min: ${getTime(d.min)}
` + + `max: ${getTime(d.max)}
` + + `avg: ${getTime(d.avg)}` + }) (document.getElementById('chart'));