mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-04-30 07:32:23 +02:00
Fix statistics for live writer
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <cstddef>
|
||||
#include <formats.hpp>
|
||||
#include <chrono>
|
||||
#include "broker_format.hpp"
|
||||
|
||||
#ifndef SF_DAQ_BUFFER_FRAMESTATS_HPP
|
||||
#define SF_DAQ_BUFFER_FRAMESTATS_HPP
|
||||
@@ -9,9 +10,12 @@
|
||||
class WriterStats {
|
||||
const std::string detector_name_;
|
||||
const size_t stats_modulo_;
|
||||
const size_t image_n_bytes_;
|
||||
|
||||
uint32_t image_n_bytes_;
|
||||
|
||||
int image_counter_;
|
||||
uint64_t total_bytes_;
|
||||
|
||||
uint32_t total_buffer_write_us_;
|
||||
uint32_t max_buffer_write_us_;
|
||||
std::chrono::time_point<std::chrono::steady_clock> stats_interval_start_;
|
||||
@@ -22,8 +26,8 @@ class WriterStats {
|
||||
public:
|
||||
WriterStats(
|
||||
const std::string &detector_name,
|
||||
const size_t stats_modulo,
|
||||
const size_t image_n_bytes);
|
||||
const size_t stats_modulo);
|
||||
void setup_run(const StoreStream& meta);
|
||||
void start_image_write();
|
||||
void end_image_write();
|
||||
};
|
||||
|
||||
@@ -6,11 +6,9 @@ using namespace chrono;
|
||||
|
||||
WriterStats::WriterStats(
|
||||
const string& detector_name,
|
||||
const size_t stats_modulo,
|
||||
const size_t image_n_bytes) :
|
||||
const size_t stats_modulo) :
|
||||
detector_name_(detector_name),
|
||||
stats_modulo_(stats_modulo),
|
||||
image_n_bytes_(image_n_bytes)
|
||||
{
|
||||
reset_counters();
|
||||
}
|
||||
@@ -20,6 +18,7 @@ void WriterStats::reset_counters()
|
||||
image_counter_ = 0;
|
||||
total_buffer_write_us_ = 0;
|
||||
max_buffer_write_us_ = 0;
|
||||
total_bytes_ = 0;
|
||||
}
|
||||
|
||||
void WriterStats::start_image_write()
|
||||
@@ -27,9 +26,17 @@ void WriterStats::start_image_write()
|
||||
stats_interval_start_ = steady_clock::now();
|
||||
}
|
||||
|
||||
void WriterStats::setup_run(const StoreStream& meta)
|
||||
{
|
||||
image_n_bytes_ = (meta.image_y_size *
|
||||
meta.image_x_size *
|
||||
meta.bits_per_pixel) / 8;
|
||||
}
|
||||
|
||||
void WriterStats::end_image_write()
|
||||
{
|
||||
image_counter_++;
|
||||
total_bytes_ += image_n_bytes_;
|
||||
|
||||
uint32_t write_us_duration = duration_cast<microseconds>(
|
||||
steady_clock::now()-stats_interval_start_).count();
|
||||
|
||||
@@ -18,17 +18,14 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
if (argc != 3) {
|
||||
cout << endl;
|
||||
cout << "Usage: jf_live_writer [detector_json_filename]"
|
||||
" [bits_per_pixel]" << endl;
|
||||
cout << "Usage: jf_live_writer [detector_json_filename]" << endl;
|
||||
cout << "\tdetector_json_filename: detector config file path." << endl;
|
||||
cout << "\tbits_per_pixel: Number of bits in each pixel." << endl;
|
||||
cout << endl;
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
auto const config = BufferUtils::read_json_config(string(argv[1]));
|
||||
auto const bits_per_pixel = atoi(argv[2]);
|
||||
|
||||
MPI_Init(NULL, NULL);
|
||||
|
||||
@@ -45,11 +42,8 @@ int main (int argc, char *argv[])
|
||||
|
||||
RamBuffer ram_buffer(config.detector_name, config.n_modules);
|
||||
|
||||
const uint64_t image_n_bytes =
|
||||
config.image_y_size * config.image_x_size * bits_per_pixel;
|
||||
|
||||
JFH5Writer writer(config);
|
||||
WriterStats stats(config.detector_name, STATS_MODULO, image_n_bytes);
|
||||
WriterStats stats(config.detector_name, STATS_MODULO);
|
||||
|
||||
StoreStream meta = {};
|
||||
while (true) {
|
||||
@@ -61,6 +55,9 @@ int main (int argc, char *argv[])
|
||||
meta.image_y_size,
|
||||
meta.image_x_size,
|
||||
meta.bits_per_pixel);
|
||||
|
||||
stats.setup_run(meta);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user