From f9152fa86159ac695ddb1ab230395b1ee2ec5196 Mon Sep 17 00:00:00 2001 From: Andrej Babic Date: Tue, 2 Jun 2020 10:48:21 +0200 Subject: [PATCH] Remove manual writer tests --- sf-writer/test/CMakeLists.txt | 11 -- sf-writer/test/manual/test_sf_writer_recv.cpp | 130 ------------------ 2 files changed, 141 deletions(-) delete mode 100644 sf-writer/test/manual/test_sf_writer_recv.cpp diff --git a/sf-writer/test/CMakeLists.txt b/sf-writer/test/CMakeLists.txt index 7666c3e..13dd5c0 100644 --- a/sf-writer/test/CMakeLists.txt +++ b/sf-writer/test/CMakeLists.txt @@ -7,14 +7,3 @@ target_link_libraries(sf-writer-tests zmq gtest ) - -add_executable(sf-writer-recv manual/test_sf_writer_recv.cpp) -set_target_properties(sf-writer-recv PROPERTIES OUTPUT_NAME sf_writer) -set_target_properties(sf-writer-recv PROPERTIES EXCLUDE_FROM_ALL TRUE) -target_link_libraries(sf-writer-recv - sf-writer-lib - zmq - hdf5 - hdf5_cpp - pthread - ) \ No newline at end of file diff --git a/sf-writer/test/manual/test_sf_writer_recv.cpp b/sf-writer/test/manual/test_sf_writer_recv.cpp deleted file mode 100644 index b78c48f..0000000 --- a/sf-writer/test/manual/test_sf_writer_recv.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include -#include "buffer_config.hpp" -#include "zmq.h" -#include -#include -#include -#include "JFH5Writer.hpp" -#include -#include -#include "date.h" -#include "bitshuffle/bitshuffle.h" -#include "WriterZmqReceiver.hpp" - -using namespace std; -using namespace core_buffer; - -void receive_replay( - void* ctx, - const string ipc_prefix, - const size_t n_modules, - FastQueue& queue, - const uint64_t start_pulse_id, - const uint64_t stop_pulse_id) -{ - try { - WriterZmqReceiver receiver(ctx, ipc_prefix, n_modules, stop_pulse_id); - - int slot_id; - while((slot_id = queue.reserve()) == -1) { - this_thread::sleep_for(chrono::milliseconds( - RB_READ_RETRY_INTERVAL_MS)); - } - - uint64_t pulse_id = start_pulse_id; - // "<= stop_pulse_id" because we include the last pulse_id. - while(pulse_id <= stop_pulse_id) { - auto start_time = chrono::steady_clock::now(); - - auto image_metadata = queue.get_metadata_buffer(slot_id); - auto image_buffer = queue.get_data_buffer(slot_id); - - receiver.get_next_buffer(pulse_id, image_metadata, image_buffer); - - pulse_id += image_metadata->n_images; - - auto end_time = chrono::steady_clock::now(); - auto read_us_duration = chrono::duration_cast( - end_time-start_time).count(); - - cout << "sf_writer::avg_read_us "; - cout << read_us_duration / image_metadata->n_images << endl; - } - - queue.commit(); - - } catch (const std::exception& e) { - using namespace date; - using namespace chrono; - - cout << "[" << system_clock::now() << "]"; - cout << "[sf_writer::receive_replay]"; - cout << " Stopped because of exception: " << endl; - cout << e.what() << endl; - - throw; - } -} - -int main (int argc, char *argv[]) -{ - if (argc != 5) { - cout << endl; - cout << "Usage: sf_writer "; - cout << " [ipc_id] [output_file] [start_pulse_id] [stop_pulse_id]"; - cout << endl; - cout << "\tipc_id: Unique identifier for ipc." << endl; - cout << "\toutput_file: Complete path to the output file." << endl; - cout << "\tstart_pulse_id: Start pulse_id of retrieval." << endl; - cout << "\tstop_pulse_id: Stop pulse_id of retrieval." << endl; - cout << endl; - - exit(-1); - } - - const string ipc_id = string(argv[1]); - string output_file = string(argv[2]); - uint64_t start_pulse_id = (uint64_t) atoll(argv[3]); - uint64_t stop_pulse_id = (uint64_t) atoll(argv[4]); - - size_t n_modules = 32; - - FastQueue queue( - MODULE_N_BYTES * n_modules * WRITER_DATA_CACHE_N_IMAGES, - WRITER_FASTQUEUE_N_SLOTS); - - auto ctx = zmq_ctx_new(); - zmq_ctx_set (ctx, ZMQ_IO_THREADS, WRITER_ZMQ_IO_THREADS); - - auto ipc_base = REPLAY_STREAM_IPC_URL + ipc_id + "-"; - - receive_replay( - ctx, ipc_base, n_modules,queue, start_pulse_id, stop_pulse_id); - -// -// -// auto current_pulse_id = start_pulse_id; -// // "<= stop_pulse_id" because we include the last pulse_id. -// while (current_pulse_id <= stop_pulse_id) { -// -// int slot_id; -// while((slot_id = queue.read()) == -1) { -// this_thread::sleep_for(chrono::milliseconds( -// RB_READ_RETRY_INTERVAL_MS)); -// } -// -// auto metadata = queue.get_metadata_buffer(slot_id); -// -// for (int i_pulse=0; i_pulse < metadata->n_images; i_pulse++) { -// cout << "Written image " << metadata->pulse_id[i_pulse] << endl; -// -// } -// -// queue.release(); -// current_pulse_id += metadata->n_images; -// } -// -// //wait till receive thread is finished -// replay_receive_thread.join(); - return 0; -}