test(zmq): addthroughput benchmark tests

Add a performance benchmark `BenchmarkThroughput` to measure the sample rate capacity

Signed-off-by: Bartosz Podrygajlo <bartosz.podrygajlo@openairinterface.org>
This commit is contained in:
Bartosz Podrygajlo
2026-07-09 08:07:30 +02:00
parent 0dab3bb6a1
commit dc35ce95b9

View File

@@ -153,6 +153,39 @@ TEST_F(ZMQTest, TxRxSamples)
t2.join(); t2.join();
} }
TEST_F(ZMQTest, BenchmarkThroughput)
{
int level = g_log->log_component[HW].level;
g_log->log_component[HW].level = OAILOG_ERR;
const size_t nsamps = 10000;
const size_t num_iters = 100000;
c16_t tx_samples[nsamps];
for (size_t i = 0; i < nsamps; i++) {
tx_samples[i].r = i;
tx_samples[i].i = i + 1;
}
void *samples[1] = {tx_samples};
openair0_timestamp_t tx_timestamp = 0;
auto start = std::chrono::high_resolution_clock::now();
for (size_t i = 0; i < num_iters; i++) {
ASSERT_EQ(device1.trx_write_func(&device1, tx_timestamp, samples, nsamps, 1, 0), nsamps);
tx_timestamp += nsamps;
}
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end - start;
std::cout << "Benchmark:" << std::endl;
std::cout << "Time taken: " << diff.count() << " s\n";
std::cout << "Throughput: " << (nsamps * num_iters) / diff.count() / 1e6 << " MSamples/s\n";
// No need to drain messages as device shutdown handles cleanup
g_log->log_component[HW].level = level;
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
logInit(); logInit();