diff --git a/std-udp-sync/include/SyncStats.hpp b/std-udp-sync/include/SyncStats.hpp index 18b9d1d..f315bea 100644 --- a/std-udp-sync/include/SyncStats.hpp +++ b/std-udp-sync/include/SyncStats.hpp @@ -7,7 +7,7 @@ class SyncStats { const std::string detector_name_; - const size_t stats_modulo_; + const size_t stats_time_; int image_counter_; int n_sync_lost_images_; @@ -18,7 +18,7 @@ class SyncStats { public: SyncStats(const std::string &detector_name, - const size_t stats_modulo); + const size_t stats_time); void record_stats(const uint32_t n_lost_pulses); }; diff --git a/std-udp-sync/include/sync_config.hpp b/std-udp-sync/include/sync_config.hpp index 253b4e2..a66e08e 100644 --- a/std-udp-sync/include/sync_config.hpp +++ b/std-udp-sync/include/sync_config.hpp @@ -2,7 +2,4 @@ namespace sync_config { // Number of times we try to re-sync in case of failure. const int SYNC_RETRY_LIMIT = 3; - - // Number of pulses between each statistics print out. - const size_t SYNC_STATS_MODULO = 1000; } diff --git a/std-udp-sync/src/SyncStats.cpp b/std-udp-sync/src/SyncStats.cpp index e9bb76d..8b86af3 100644 --- a/std-udp-sync/src/SyncStats.cpp +++ b/std-udp-sync/src/SyncStats.cpp @@ -7,9 +7,9 @@ using namespace chrono; SyncStats::SyncStats( const std::string &detector_name, - const size_t stats_modulo) : + const size_t stats_time) : detector_name_(detector_name), - stats_modulo_(stats_modulo) + stats_time_(stats_time) { reset_counters(); } @@ -26,7 +26,10 @@ void SyncStats::record_stats(const uint32_t n_lost_pulses) image_counter_++; n_sync_lost_images_ += n_lost_pulses; - if (image_counter_ == stats_modulo_) { + const auto time_passed = duration_cast( + steady_clock::now()-stats_interval_start_).count(); + + if (time_passed >= stats_time_*1000) { print_stats(); reset_counters(); } diff --git a/std-udp-sync/src/main.cpp b/std-udp-sync/src/main.cpp index b2d5150..b782884 100644 --- a/std-udp-sync/src/main.cpp +++ b/std-udp-sync/src/main.cpp @@ -49,7 +49,7 @@ int main (int argc, char *argv[]) FRAME_N_BYTES, config.n_modules, RAM_BUFFER_N_SLOTS); ZmqPulseSyncReceiver receiver(ctx, config.detector_name, config.n_modules); - SyncStats stats(config.detector_name, SYNC_STATS_MODULO); + SyncStats stats(config.detector_name, STATS_TIME); while (true) { auto meta = receiver.get_next_pulse_id();