mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-11 01:12:03 +02:00
Add performance test
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
SRC_DIR = .
|
||||
OBJ_DIR = ./obj
|
||||
BIN_DIR = ./bin
|
||||
MKDIR = mkdir -p
|
||||
|
||||
CC = g++
|
||||
CFLAGS = -Wall -Wfatal-errors -std=c++11 -I${CONDA_PREFIX}/include -I${CONDA_PREFIX}/include/cpp_h5_writer
|
||||
LDFLAGS = -L${CONDA_PREFIX}/lib -L/usr/lib64 -lcpp_h5_writer -lzmq -lhdf5 -lhdf5_hl -lhdf5_cpp -lhdf5_hl_cpp -lboost_system -lboost_regex -lboost_thread -lpthread
|
||||
|
||||
HEADERS = $(wildcard $(SRC_DIR)/*.hpp)
|
||||
SRCS = $(wildcard $(SRC_DIR)/*.cpp)
|
||||
OBJS = $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRCS))
|
||||
|
||||
h5_write_perf: export LD_LIBRARY_PATH=${CONDA_PREFIX}/lib
|
||||
h5_write_perf: CFLAGS += -DDEBUG_OUTPUT -g
|
||||
h5_write_perf: lib build_dirs $(OBJS)
|
||||
$(CC) $(LDFLAGS) -o $(BIN_DIR)/h5_write_perf $(OBJS) $(LDFLAGS)
|
||||
|
||||
lib:
|
||||
$(MAKE) -C ../lib deploy
|
||||
|
||||
deploy: h5_write_perf
|
||||
cp bin/* ${CONDA_PREFIX}/bin
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -c -o $@ $<
|
||||
|
||||
build_dirs:
|
||||
$(MKDIR) $(OBJ_DIR) $(BIN_DIR)
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJ_DIR) $(BIN_DIR)
|
||||
@@ -0,0 +1,50 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "H5Writer.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
if (argc != 5) {
|
||||
cout << endl;
|
||||
cout << "Usage: h5_write_perf [output_file] [n_frames] [frame_size_x] [frame_size_y]" << endl;
|
||||
cout << "\toutput_file: Name of the output file." << endl;
|
||||
cout << "\tn_frames: Number of images to write." << endl;
|
||||
cout << "\frame_size_x: Frame width in pixels." << endl;
|
||||
cout << "\frame_size_y: Frame height in pixels." << endl;
|
||||
cout << endl;
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
string output_file = string(argv[1]);
|
||||
int n_frames = atoi(argv[2]);
|
||||
int frame_size_x = atoi(argv[3]);
|
||||
int frame_size_y = atoi(argv[4]);
|
||||
|
||||
H5Writer writer(output_file, n_frames, n_frames, n_frames);
|
||||
|
||||
size_t buffer_length = frame_size_x * frame_size_y * sizeof(u_int16_t);
|
||||
char* buffer = new char[buffer_length];
|
||||
|
||||
string dataset_name = "data";
|
||||
|
||||
for (size_t index=0; index<n_frames; index++) {
|
||||
writer.write_data(dataset_name,
|
||||
index,
|
||||
buffer,
|
||||
{frame_size_y, frame_size_x},
|
||||
buffer_length,
|
||||
"uint16",
|
||||
"little");
|
||||
}
|
||||
|
||||
writer.close_file();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user