So I'm trying to get some throughput measurements on an I/O library I'm working on, and I'm currently testing a synchronous mode so that I need two threads, one to read data and one to write.
The code is quite simple:
template <typename T>
void sync_read_loop(pf_istream *in_sock, T *buffer, uint32_t iters) {
for (int ii=0; ii < iters; ii++) {
(*in_sock) >> buffer;
}
}
template <typename T>
void sync_write_loop(pf_ostream *out_sock, T *buffer, uint32_t iters) {
for (int ii=0; ii < iters; ii++) {
(*out_sock) << buffer;
}
}
template <typename T>
void TEST_READ_WRITE(const char* msg, t_pf_type pf_type, bool &all_passed, T (*randnum)(), bool throughput, bool sync) {
const size_t BUFF_SIZE = 1024*1024;
const size_t ITERS = 32;
T* write_buffer = (T*)(new char[BUFF_SIZE*sizeof(T)]);
T* read_buffer = (T*)(new char[BUFF_SIZE*sizeof(T)]);
if (sync) {