From 868d58627808b03d77d3df7d6f9e182de98d69d1 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 15 Jun 2011 13:51:28 -0700 Subject: uhd: added dropped samples calculation to rx test --- host/examples/benchmark_rate.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'host') diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index a66acac41..a9bbc1265 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -30,6 +31,7 @@ unsigned long long num_overflows = 0; unsigned long long num_underflows = 0; unsigned long long num_rx_samps = 0; unsigned long long num_tx_samps = 0; +unsigned long long num_dropped_samps = 0; /*********************************************************************** * Benchmark RX Rate @@ -46,6 +48,9 @@ void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp){ uhd::rx_metadata_t md; const size_t max_samps_per_packet = usrp->get_device()->get_max_recv_samps_per_packet(); std::vector > buff(max_samps_per_packet); + bool had_an_overflow = false; + uhd::time_spec_t last_time; + const double rate = usrp->get_rx_rate(); usrp->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); while (not boost::this_thread::interruption_requested()){ @@ -58,9 +63,15 @@ void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp){ //handle the error codes switch(md.error_code){ case uhd::rx_metadata_t::ERROR_CODE_NONE: + if (had_an_overflow){ + had_an_overflow = false; + num_dropped_samps += boost::math::iround((md.time_spec - last_time).get_real_secs()*rate); + } break; case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW: + had_an_overflow = true; + last_time = md.time_spec; num_overflows++; break; @@ -210,10 +221,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << std::endl << boost::format( "Benchmark rate summary:\n" " Num received samples: %u\n" + " Num dropped samples: %u\n" " Num overflows detected: %u\n" " Num transmitted samples: %u\n" " Num underflows detected: %u\n" - ) % num_rx_samps % num_overflows % num_tx_samps % num_overflows << std::endl; + ) % num_rx_samps % num_dropped_samps % num_overflows % num_tx_samps % num_overflows << std::endl; //finished std::cout << std::endl << "Done!" << std::endl << std::endl; -- cgit v1.2.3