Use stats time instead of modulo

This commit is contained in:
2021-07-19 14:07:53 +02:00
parent 8a88a1b1da
commit 0d0e23b507
4 changed files with 9 additions and 9 deletions
+2 -2
View File
@@ -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);
};
-3
View File
@@ -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;
}
+6 -3
View File
@@ -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<milliseconds>(
steady_clock::now()-stats_interval_start_).count();
if (time_passed >= stats_time_*1000) {
print_stats();
reset_counters();
}
+1 -1
View File
@@ -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();