aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2021-09-22 16:17:08 +0200
committerAaron Rossetto <aaron.rossetto@ni.com>2021-09-28 06:25:25 -0700
commitb34e2f05938a0af11d7c49510512490fc41e1af4 (patch)
tree7fb26dc3fcffdb4eeb8745526aefb516edb90c1e /host/examples
parent30a40395b92fa31ad74c0435a970e92c90a942d4 (diff)
downloaduhd-b34e2f05938a0af11d7c49510512490fc41e1af4.tar.gz
uhd-b34e2f05938a0af11d7c49510512490fc41e1af4.tar.bz2
uhd-b34e2f05938a0af11d7c49510512490fc41e1af4.zip
python: Fix dropped-sample calculation in benchmark_rate.py
This fixes a subtle bug, where a variable to cache the timestamp of an error gets bound to the metadata instead of creating a copy thereof. Without this fix, the calculation of dropped samples would always be 0, because the difference in timestamps would incorrectly be always zero. This fix will now make a copy of the timestamp. Shoutout to GitHub user bhorsfield for finding this issue.
Diffstat (limited to 'host/examples')
-rwxr-xr-xhost/examples/python/benchmark_rate.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/host/examples/python/benchmark_rate.py b/host/examples/python/benchmark_rate.py
index a2ef1047b..35230599f 100755
--- a/host/examples/python/benchmark_rate.py
+++ b/host/examples/python/benchmark_rate.py
@@ -210,16 +210,18 @@ def benchmark_rx_rate(usrp, rx_streamer, random, timer_elapsed_event, rx_statist
# Reset the overflow flag
if had_an_overflow:
had_an_overflow = False
- num_rx_dropped += uhd.types.TimeSpec(
- metadata.time_spec.get_real_secs() - last_overflow.get_real_secs()
- ).to_ticks(rate)
+ num_rx_dropped += (metadata.time_spec - last_overflow).to_ticks(rate)
elif metadata.error_code == uhd.types.RXMetadataErrorCode.overflow:
had_an_overflow = True
- last_overflow = metadata.time_spec
+ # Need to make sure that last_overflow is a new TimeSpec object, not
+ # a reference to metadata.time_spec, or it would not be useful
+ # further up.
+ last_overflow = uhd.types.TimeSpec(
+ metadata.time_spec.get_full_secs(),
+ metadata.time_spec.get_frac_secs())
# If we had a sequence error, record it
if metadata.out_of_sequence:
num_rx_seqerr += 1
- logger.warning("Detected RX sequence error.")
# Otherwise just count the overrun
else:
num_rx_overruns += 1