diff options
author | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-03-04 12:00:47 -0600 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-03-07 09:21:49 -0600 |
commit | 7e8c52d80793e4f406177e82602cdf293a8a7fa8 (patch) | |
tree | b4f2226c90619d33c8273705e3f05c3001f0d9b7 | |
parent | 89258f2d1855a3a9f3de1813c1ccc3faddfb7756 (diff) | |
download | uhd-7e8c52d80793e4f406177e82602cdf293a8a7fa8.tar.gz uhd-7e8c52d80793e4f406177e82602cdf293a8a7fa8.tar.bz2 uhd-7e8c52d80793e4f406177e82602cdf293a8a7fa8.zip |
tests: Atomicize counters in benchmark_rate
The counters that keep track of overruns, underruns, number of samples
transferred, etc., were not atomic. Thus, running benchmark_rate with
multiple threads would result in inaccurate statistics being reported at
the end of the run. This commit makes those counters atomic variables so
that they are updated properly.
-rw-r--r-- | host/examples/benchmark_rate.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index 5a3f5f181..41d3ff462 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -32,16 +32,16 @@ using start_time_type = std::chrono::time_point<std::chrono::steady_clock>; /*********************************************************************** * Test result variables **********************************************************************/ -unsigned long long num_overruns = 0; -unsigned long long num_underruns = 0; -unsigned long long num_rx_samps = 0; -unsigned long long num_tx_samps = 0; -unsigned long long num_dropped_samps = 0; -unsigned long long num_seq_errors = 0; -unsigned long long num_seqrx_errors = 0; // "D"s -unsigned long long num_late_commands = 0; -unsigned long long num_timeouts_rx = 0; -unsigned long long num_timeouts_tx = 0; +std::atomic_ullong num_overruns{0}; +std::atomic_ullong num_underruns{0}; +std::atomic_ullong num_rx_samps{0}; +std::atomic_ullong num_tx_samps{0}; +std::atomic_ullong num_dropped_samps{0}; +std::atomic_ullong num_seq_errors{0}; +std::atomic_ullong num_seqrx_errors{0}; // "D"s +std::atomic_ullong num_late_commands{0}; +std::atomic_ullong num_timeouts_rx{0}; +std::atomic_ullong num_timeouts_tx{0}; inline auto time_delta(const start_time_type& ref_time) { |