netutils/iperf: guaranteed precision before division

Iperf test on photon/wlan
Before:
   0.00-   1.08 sec      65536 Bytes    0.00 Mbits/sec
After:
   0.00-   1.04 sec      74970 Bytes    0.58 Mbits/sec

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-03-22 15:05:58 +08:00 committed by Alan Carvalho de Assis
parent 412505d286
commit b3cfcee47d

View File

@ -272,7 +272,7 @@ static void iperf_report_task(FAR void *arg)
ts_diff(&last, &start), ts_diff(&last, &start),
ts_diff(&now, &start), ts_diff(&now, &start),
now_len -last_len, now_len -last_len,
(double)((now_len - last_len) * 8 / 1000000) / ((double)((now_len - last_len) * 8) / 1000000) /
(double)ts_diff(&now, &last) (double)ts_diff(&now, &last)
); );
if (time != 0 && ts_diff(&now, &start) >= time) if (time != 0 && ts_diff(&now, &start) >= time)
@ -287,7 +287,7 @@ static void iperf_report_task(FAR void *arg)
ts_diff(&start, &start), ts_diff(&start, &start),
ts_diff(&now, &start), ts_diff(&now, &start),
now_len, now_len,
(double)(now_len * 8 / 1000000) / ((double)(now_len * 8) / 1000000) /
(double)ts_diff(&now, &start) (double)ts_diff(&now, &start)
); );
} }