metrics_stdout: fix precision calculation for 100%

the precision for 100% was causing the default value of -1 which in turn
cause to print the full precision resulting in ugly stdout plots.

before:
--------Signal--------------DL-------------------------------------UL----------------------
cc pci  rsrp    pl    cfo   mcs   snr turbo  brate   bler   ta_us  mcs   buff  brate   bler
 0   0   -10    74    0.0   0.0   0.0   0.0   200k     0%   0.0   0.0    0.0    0.0     0%
 1   0   0.0   0.0    0.0   0.0   0.0   0.0   150k100.000000%   0.0   0.0    0.0    0.0     0%

after:
--------Signal--------------DL-------------------------------------UL----------------------
cc pci  rsrp    pl    cfo   mcs   snr turbo  brate   bler   ta_us  mcs   buff  brate   bler
 0   0   -10    74    0.0   0.0   0.0   0.0   200k     0%   0.0   0.0    0.0    0.0     0%
 1   0   0.0   0.0    0.0   0.0   0.0   0.0   150k   100%   0.0   0.0    0.0    0.0     0%
master
Andre Puschmann 4 years ago
parent e72219789e
commit 829dfc4e60

@ -178,7 +178,8 @@ void metrics_stdout::set_metrics(const ue_metrics_t& metrics, const uint32_t per
std::string metrics_stdout::float_to_string(float f, int digits)
{
std::ostringstream os;
const int precision = SRSLTE_MIN((int)((f == 0.0f) ? digits - 1 : digits - log10f(fabsf(f)) - 2 * FLT_EPSILON), 3);
const int precision =
SRSLTE_MIN((int)((f == 0.0f || f == 100.0f) ? digits - 1 : digits - log10f(fabsf(f)) - 2 * FLT_EPSILON), 3);
os << std::setw(6) << std::fixed << std::setprecision(precision) << f;
return os.str();
}

@ -53,7 +53,7 @@ public:
m->stack.mac[0].nof_tti = 1;
m->stack.mac[1].rx_pkts = 100;
m->stack.mac[1].rx_errors = 50;
m->stack.mac[1].rx_errors = 100;
m->stack.mac[1].rx_brate = 150;
m->stack.mac[1].nof_tti = 1;

Loading…
Cancel
Save