From 36b2d71c26baefa4318383326e0fec61d5aa3616 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 19 Mar 2019 06:27:33 +0100 Subject: logic/pipeline: improve DEBUG_TIMINGS --- logic/pipeline.cpp | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp index 1cd23110..130b7eff 100644 --- a/logic/pipeline.cpp +++ b/logic/pipeline.cpp @@ -29,6 +29,11 @@ # include #endif +//#define DEBUG_TIMINGS +#ifdef DEBUG_TIMINGS +# include "compat/variance.hpp" +#endif + namespace pipeline_impl { reltrans::reltrans() = default; @@ -198,7 +203,6 @@ double pipeline::map(double pos, Map& axis) return fc.get_value(pos); } -//#define DEBUG_TIMINGS template static inline bool is_nan(const dmat& r) { @@ -535,18 +539,30 @@ void pipeline::run() #ifdef DEBUG_TIMINGS { + static variance v; + static Timer tt, t2; static int cnt; - static Timer tt; - if (tt.elapsed_seconds() >= 1) + + v.input(t2.elapsed_ms()); + + if (tt.elapsed_ms() >= 1000) { tt.start(); - qDebug() << cnt << "Hz" - << "sleepy time" << sleep_time_ms - << "diff" << ms{elapsed_nsecs}.count() - ms{const_sleep_ms}.count() - << "backlog" << ms{backlog_time}.count(); + qDebug() << cnt << "Hz," + << "loop: " "time" << v.avg() + << "stddev:" << v.stddev() + << "backlog" << ms{backlog_time}.count() + << "sleep" << sleep_time_ms << "ms"; + + if (v.count() > 256 * 60) + v.clear(); + cnt = 0; } + cnt++; + + t2.start(); } #endif -- cgit v1.2.3