aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrent Stapleton <brent.stapleton@ettus.com>2018-12-20 18:53:28 -0800
committerBrent Stapleton <brent.stapleton@ettus.com>2019-01-03 09:20:18 -0800
commita7bd625203816837cd25ca06f79bef22caf4fa90 (patch)
tree7bf982e8bb7653de16fecb288b765ee4f1e8fb51
parente3fd16a867a8e964aabbbb5fa050b69041109e78 (diff)
downloaduhd-a7bd625203816837cd25ca06f79bef22caf4fa90.tar.gz
uhd-a7bd625203816837cd25ca06f79bef22caf4fa90.tar.bz2
uhd-a7bd625203816837cd25ca06f79bef22caf4fa90.zip
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.
-rw-r--r--host/examples/benchmark_rate.cpp6
1 files changed, 3 insertions, 3 deletions
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<char> buff(max_samps_per_packet*uhd::convert::get_bytes_per_item(tx_cpu));
std::vector<const void *> 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));