From d2c89fd58b7dc68f3fe507853acfd5c135c8d17f Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 8 Oct 2017 18:31:04 +0200 Subject: Avoid flowgraph timing fprintf mixup on console --- src/Flowgraph.cpp | 15 ++++++++++++--- 1 file 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 #include +#include #if HAVE_DECL__MM_MALLOC # include @@ -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()); } } -- cgit v1.2.3