mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-02 23:54:12 +02:00
Added back statistics manually
This commit is contained in:
+35
-20
@@ -20,45 +20,60 @@ void sf_replay (
|
||||
const uint64_t start_pulse_id,
|
||||
const uint64_t stop_pulse_id)
|
||||
{
|
||||
auto m_buffer = new ReplayModuleFrameBuffer();
|
||||
auto m_buffer_size = sizeof(ReplayModuleFrameBuffer);
|
||||
auto f_buffer = new char[MODULE_N_BYTES * REPLAY_READ_BUFFER_SIZE];
|
||||
uint64_t read_us = 0;
|
||||
uint64_t max_read_us = 0;
|
||||
uint64_t send_us = 0;
|
||||
uint64_t max_send_us = 0;
|
||||
uint64_t n_stats = 0;
|
||||
|
||||
ReplayH5Reader file_reader(device, channel_name, source_id, stop_pulse_id);
|
||||
|
||||
uint64_t curr_pulse_id = start_pulse_id;
|
||||
// "<= stop_pulse_id" because we include the stop_pulse_id in the file.
|
||||
while (curr_pulse_id <= stop_pulse_id) {
|
||||
for (uint64_t curr_pulse_id=start_pulse_id;
|
||||
curr_pulse_id <= stop_pulse_id;
|
||||
curr_pulse_id++) {
|
||||
|
||||
auto start_time = steady_clock::now();
|
||||
|
||||
ModuleFrame* m_buffer;
|
||||
char* f_buffer;
|
||||
file_reader.get_buffer(curr_pulse_id, m_buffer, f_buffer);
|
||||
|
||||
auto end_time = steady_clock::now();
|
||||
auto read_us_duration =
|
||||
uint64_t read_us_duration =
|
||||
duration_cast<microseconds>(end_time-start_time).count();
|
||||
|
||||
start_time = steady_clock::now();
|
||||
|
||||
zmq_send(socket, m_buffer, m_buffer_size, ZMQ_SNDMORE);
|
||||
zmq_send(socket, f_buffer, m_buffer->data_n_bytes, 0);
|
||||
zmq_send(socket, m_buffer, sizeof(ModuleFrame), ZMQ_SNDMORE);
|
||||
zmq_send(socket, f_buffer, MODULE_N_BYTES, 0);
|
||||
|
||||
end_time = steady_clock::now();
|
||||
|
||||
curr_pulse_id += m_buffer->n_frames;
|
||||
|
||||
auto send_us_duration =
|
||||
uint64_t send_us_duration =
|
||||
duration_cast<microseconds>(end_time-start_time).count();
|
||||
auto avg_read_us = read_us_duration / m_buffer->n_frames;
|
||||
auto avg_send_us = send_us_duration / m_buffer->n_frames;
|
||||
|
||||
cout << "sf_replay:avg_read_us " << avg_read_us;
|
||||
cout << " sf_replay:avg_send_us " << avg_send_us;
|
||||
cout << endl;
|
||||
// TODO: Proper statistics
|
||||
n_stats++;
|
||||
|
||||
read_us += read_us_duration;
|
||||
max_read_us = max(max_read_us, read_us_duration);
|
||||
send_us += send_us_duration;
|
||||
max_send_us = max(max_send_us, send_us_duration);
|
||||
|
||||
if (n_stats == STATS_MODULO) {
|
||||
cout << "sf_replay:avg_read_us " << read_us / STATS_MODULO;
|
||||
cout << " sf_replay:max_read_us " << max_read_us;
|
||||
cout << " sf_replay:avg_send_us " << send_us / STATS_MODULO;
|
||||
cout << " sf_replay:max_send_us " << max_send_us;
|
||||
cout << endl;
|
||||
|
||||
n_stats = 0;
|
||||
read_us = 0;
|
||||
max_read_us = 0;
|
||||
send_us = 0;
|
||||
max_send_us = 0;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] f_buffer;
|
||||
delete m_buffer;
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
|
||||
Reference in New Issue
Block a user