From a7bd625203816837cd25ca06f79bef22caf4fa90 Mon Sep 17 00:00:00 2001 From: Brent Stapleton Date: Thu, 20 Dec 2018 18:53:28 -0800 Subject: examples: optimize benchmark_rate start time Move the setting of the streaming start times back as late as possible. Currently, there are memory allocations in between setting the time_spec in the TX metadata and actually starting streaming. This will lessen the need for an INIT_DELAY and decrease the probability of late packets. --- host/examples/benchmark_rate.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'host/examples') diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index 3a089dc62..676b2139b 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -192,15 +192,15 @@ void benchmark_tx_rate( ) % NOW() % (usrp->get_tx_rate()/1e6) % tx_stream->get_num_channels() << std::endl; //setup variables and allocate buffer - uhd::tx_metadata_t md; - md.time_spec = usrp->get_time_now() + uhd::time_spec_t(INIT_DELAY); - md.has_time_spec = (tx_stream->get_num_channels() > 1); const size_t max_samps_per_packet = tx_stream->get_max_num_samps(); std::vector buff(max_samps_per_packet*uhd::convert::get_bytes_per_item(tx_cpu)); std::vector buffs; for (size_t ch = 0; ch < tx_stream->get_num_channels(); ch++) buffs.push_back(&buff.front()); //same buffer for each channel + // Create the metadata, and populate the time spec at the latest possible moment + uhd::tx_metadata_t md; md.has_time_spec = (buffs.size() != 1); + md.time_spec = usrp->get_time_now() + uhd::time_spec_t(INIT_DELAY); if (random_nsamps) { std::srand((unsigned int)time(NULL)); -- cgit v1.2.3