From 3715980e5cb1e628a8fef1ee7d6f76c4f12157f7 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 24 Jul 2018 08:54:02 +0200 Subject: zmq2edi: Display number of late frames in stats --- src/zmq2edi/EDISender.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/zmq2edi/EDISender.cpp b/src/zmq2edi/EDISender.cpp index 38fcae9..9cd84c7 100644 --- a/src/zmq2edi/EDISender.cpp +++ b/src/zmq2edi/EDISender.cpp @@ -241,14 +241,11 @@ void EDISender::send_eti_frame(uint8_t* p, metadata_t metadata) etiLog.level(debug) << "wait " << wait_time.count(); */ + const auto wait_time = t_release - t_now; if (t_release > t_now) { - const auto wait_time = t_release - t_now; std::this_thread::sleep_for(wait_time); - wait_times.push_back(duration_cast(wait_time).count()); - } - else { - wait_times.push_back(0); } + wait_times.push_back(duration_cast(wait_time).count()); edi_tagDETI.tsta = tist; edi_tagDETI.atstf = 1; @@ -342,6 +339,8 @@ void EDISender::process() const double n = wait_times.size(); double sum = accumulate(wait_times.begin(), wait_times.end(), 0); + size_t num_late = std::count_if(wait_times.begin(), wait_times.end(), + [](double v){ return v < 0; }); double mean = sum / n; double sq_sum = 0; @@ -360,12 +359,14 @@ void EDISender::process() etiLog.level(debug) << ss.str(); */ - etiLog.level(info) << "Wait time statistics:" + etiLog.level(info) << "Wait time statistics [microseconds]:" " min: " << *min_max.first << " max: " << *min_max.second << " mean: " << mean << " stdev: " << stdev << - " microseconds"; + " late: " << + num_late << " of " << wait_times.size() << " (" << + num_late * 100.0 / n << "%)"; wait_times.clear(); } -- cgit v1.2.3