zephyr/subsys/net/lib/zperf
Nicolas Pitre bd3ed97230 subsys/net: zperf_udp_uploader: Remove sys_clock_timeout_end_calc() usage
The initial goal was to remove sys_clock_timeout_end_calc(). However,
several related issues have been fixed as well.

First this:

    int64_t print_interval = sys_clock_timeout_end_calc(K_SECONDS(1));
    /* Print log every seconds */
    int64_t print_info = print_interval - k_uptime_ticks();

    if (print_info <= 0) {
        [...]
    }

The above condition will simply never be true.

Then there is lots of back-and-forth time conversions using expensive
base-10 divisions for each loop iterations which is likely to impact
performance.

Let's do the time conversion only once outside the loop and track
everything in terms of ticks within the loop. Also the various timeouts
are open-coded based on the absolute uptime tick so to sample it only
once per round. Using sys_timepoint_calc() and sys_timepoint_timeout()
would have introduced additional uptime tick sampling which implies the
overhead of a downstream lock each time for no gain. For those reasons,
open coding those timeouts bears more benefits in this particular case
compared to using the timepoint API.

Then this:

    secs = k_ticks_to_ms_ceil32(loop_time) / 1000U;
    usecs = k_ticks_to_us_ceil32(loop_time) - secs * USEC_PER_SEC;

The above should round down not up to work accurately. And the usecs
value will become garbage past 1.2 hour of runtime due to overflows.

And no need to clamp the wait period which is on the microsec scale
using the total duration argument being on the millisec scale. That's
yet more loop overhead that can be omitted. The actual duration is
recorded at the end anyway.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00
..
CMakeLists.txt
Kconfig net: zperf: Make Zperf worker thread stack size configurable 2023-03-20 10:20:00 +00:00
zperf_common.c net: lib: zperf: fix kernel panic due to invalid thread prio 2023-06-13 06:58:15 -04:00
zperf_internal.h
zperf_session.c net: zperf: unify get_session among TCP and UDP 2023-02-28 18:12:52 +01:00
zperf_session.h net: zperf: unify get_session among TCP and UDP 2023-02-28 18:12:52 +01:00
zperf_shell.c net: lib: zperf: Add support to disable Nagle's algorithm 2023-02-20 09:53:43 +01:00
zperf_tcp_receiver.c subsys/net: Labels cannot be applied to declarations 2023-04-05 10:38:34 +02:00
zperf_tcp_uploader.c subsys/net: zperf_tcp_uploader: move to timepoint API 2023-07-25 09:12:26 +02:00
zperf_udp_receiver.c
zperf_udp_uploader.c subsys/net: zperf_udp_uploader: Remove sys_clock_timeout_end_calc() usage 2023-07-25 09:12:26 +02:00