aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-08 18:31:04 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-08 18:31:04 +0200
commitd2c89fd58b7dc68f3fe507853acfd5c135c8d17f (patch)
tree1802c569ea53734119406bf74e5a3f5b4535f24b
parent7f8d58d762743a97fa08bfaf048428413124fcd9 (diff)
downloaddabmod-d2c89fd58b7dc68f3fe507853acfd5c135c8d17f.tar.gz
dabmod-d2c89fd58b7dc68f3fe507853acfd5c135c8d17f.tar.bz2
dabmod-d2c89fd58b7dc68f3fe507853acfd5c135c8d17f.zip
Avoid flowgraph timing fprintf mixup on console
-rw-r--r--src/Flowgraph.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Flowgraph.cpp b/src/Flowgraph.cpp
index ae75808..6ee7b81 100644
--- a/src/Flowgraph.cpp
+++ b/src/Flowgraph.cpp
@@ -28,6 +28,7 @@
#include "PcDebug.h"
#include <memory>
#include <algorithm>
+#include <sstream>
#if HAVE_DECL__MM_MALLOC
# include <mm_malloc.h>
@@ -190,18 +191,26 @@ Flowgraph::~Flowgraph()
{
PDEBUG("Flowgraph::~Flowgraph() @ %p\n", this);
+ stringstream ss;
+
if (myProcessTime) {
- fprintf(stderr, "Process time:\n");
+ ss << "Process time:\n";
+
+ char node_time_sz[1024] = {};
for (const auto &node : nodes) {
- fprintf(stderr, " %30s: %10lu us (%2.2f %%)\n",
+ snprintf(node_time_sz, 1023, " %30s: %10lu us (%2.2f %%)\n",
node->plugin()->name(),
node->processTime(),
node->processTime() * 100.0 / myProcessTime);
+ ss << node_time_sz;
}
- fprintf(stderr, " %30s: %10lu us (100.00 %%)\n", "total",
+ snprintf(node_time_sz, 1023, " %30s: %10lu us (100.00 %%)\n", "total",
myProcessTime);
+ ss << node_time_sz;
+
+ fprintf(stderr, "%s", ss.str().c_str());
}
}