From ac9dc6f31d876a49d84ffab3fe669e282dd54ba6 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Mon, 17 May 2021 09:59:29 +0200 Subject: [PATCH] Compute Performance --- srsue/hdr/phy/scell/intra_measure_nr.h | 16 ++++++++++++++++ srsue/src/phy/scell/intra_measure_nr.cc | 10 ++++++++++ srsue/test/phy/nr_cell_search_test.cc | 2 ++ 3 files changed, 28 insertions(+) diff --git a/srsue/hdr/phy/scell/intra_measure_nr.h b/srsue/hdr/phy/scell/intra_measure_nr.h index 97ad2aae3..ee2e8386d 100644 --- a/srsue/hdr/phy/scell/intra_measure_nr.h +++ b/srsue/hdr/phy/scell/intra_measure_nr.h @@ -86,6 +86,18 @@ public: */ uint32_t get_earfcn() const override { return current_arfcn; }; + /** + * @brief Computes the average measurement performance since last configuration + * @return The performance in Millions of samples per second + */ + uint32_t get_perf() const + { + if (perf_count_us == 0) { + return 0; + } + return (uint32_t)(perf_count_samples / perf_count_us); + }; + private: /** * @brief Provides with the RAT to the base class @@ -107,6 +119,10 @@ private: float thr_snr_db = 5.0f; int serving_cell_pci = -1; + /// Performance + uint64_t perf_count_us = 0; ///< Counts execution time in microseconds + uint64_t perf_count_samples = 0; ///< Counts the number samples + /// NR-based measuring objects srsran_ssb_t ssb = {}; ///< SS/PBCH Block }; diff --git a/srsue/src/phy/scell/intra_measure_nr.cc b/srsue/src/phy/scell/intra_measure_nr.cc index 6e6c02414..f3fc22877 100644 --- a/srsue/src/phy/scell/intra_measure_nr.cc +++ b/srsue/src/phy/scell/intra_measure_nr.cc @@ -60,6 +60,10 @@ bool intra_measure_nr::set_config(uint32_t arfcn, const config_t& cfg) current_arfcn = arfcn; serving_cell_pci = cfg.serving_cell_pci; + // Reset performance measurement + perf_count_samples = 0; + perf_count_us = 0; + // Configure generic side intra_measure_base::args_t base_cfg = {}; base_cfg.srate_hz = cfg.srate_hz; @@ -84,6 +88,8 @@ bool intra_measure_nr::set_config(uint32_t arfcn, const config_t& cfg) void intra_measure_nr::measure_rat(const measure_context_t& context, std::vector& buffer) { + std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now(); + // Search and measure the best cell srsran_csi_trs_measurements_t meas = {}; uint32_t N_id = 0; @@ -91,6 +97,10 @@ void intra_measure_nr::measure_rat(const measure_context_t& context, std::vector Log(error, "Error searching for SSB"); } + std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); + perf_count_us += std::chrono::duration_cast(end - begin).count(); + perf_count_samples += context.sf_len * context.meas_len_ms; + // Early return if the found PCI matches with the serving cell ID if (serving_cell_pci == (int)N_id) { return; diff --git a/srsue/test/phy/nr_cell_search_test.cc b/srsue/test/phy/nr_cell_search_test.cc index 3fe6a1979..536f26db5 100644 --- a/srsue/test/phy/nr_cell_search_test.cc +++ b/srsue/test/phy/nr_cell_search_test.cc @@ -489,6 +489,8 @@ int main(int argc, char** argv) // Stop, it will block until the asynchronous thread quits intra_measure.stop(); + logger.warning("NR intra frequency performance %d Msps\n", intra_measure.get_perf()); + ret = rrc.print_stats(args) ? SRSRAN_SUCCESS : SRSRAN_ERROR; if (radio) {