mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-11 17:25:35 +02:00
Use stats time instead of modulo
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user